You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Released to the public domain wherever applicable. Elsewhere, consider it released under the <ahref="http://www.wtfpl.net/txt/copying/">WTFPLv2</a>.</p>
224
224
<p>Linted by <ahref="https://github.com/koalaman/shellcheck">#ShellCheck</a></p>
225
225
<h2>Prerequisites</h2>
226
-
<p>Uses <ahref="http://github.com/dominictarr/JSON.sh">JSON.sh</a> and the magic of sed.</p>
227
-
<p>Bashbot is written in bash. It depends on commands typically available in a Linux/Unix Environment. For more concrete information on the common commands provided by recent versions of <ahref="https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands">coreutils</a>, <ahref="https://en.wikipedia.org/wiki/BusyBox#Commands">busybox</a> or <ahref="https://landley.net/toybox/help.html">toybox</a>, see <ahref="doc/7_develop.md#common-commands">Developer Notes</a>.</p>
226
+
<p>Uses <ahref="http://github.com/dominictarr/JSON.sh">JSON.sh</a>/<ahref="https://github.com/step-/JSON.awk">JSON.awk</a> and the magic of sed.</p>
227
+
<p>Bashbot is written in bash. It depends on commands typically available in a Linux/Unix Environment. For more information on commands provided by recent versions of <ahref="https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands">coreutils</a>, <ahref="https://en.wikipedia.org/wiki/BusyBox#Commands">busybox</a> or <ahref="https://landley.net/toybox/help.html">toybox</a>, see <ahref="doc/7_develop.md#common-commands">Developer Notes</a>.</p>
228
228
<p><strong>Note for MacOS and BSD Users:</strong> Bashbot will not run without installing additional software as it uses modern bash and (gnu) grep/sed features. See <ahref="doc/0_install.md">Install Bashbot</a>.</p>
229
229
<p><strong>Note for embedded systems:</strong> You need to install a "real" bash as the vanilla installation of busybox or toybox is not sufficient. See <ahref="doc/0_install.md">Install Bashbot</a>.</p>
230
230
<p>Bashbot <ahref="https://github.com/topkecleon/telegram-bot-bash">Documentation</a> and <ahref="https://github.com/topkecleon/telegram-bot-bash/releases">Downloads</a> are available on <ahref="https://www.github.com">www.github.com</a>.</p>
<p>To install and run bashbot you need access to a Linux/Unix command line with bash, a <ahref="https://telegram.org">Telegram client</a> and a mobile phone <ahref="https://telegramguide.com/create-a-telegram-account/">with a Telegram account</a>.</p>
<p>Running a Telegram Bot means it is connected to the public and you never know what's send to your Bot.</p>
341
342
<p>Bash scripts in general are not designed to be bulletproof, so consider this Bot as a proof of concept. Bash programmers often struggle with 'quoting hell' and globbing, see <ahref="https://unix.stackexchange.com/questions/171346/security-implications-of-forgetting-to-quote-a-variable-in-bash-posix-shells">Implications of wrong quoting</a>.</p>
342
343
<p>Whenever you are processing input from untrusted sources (messages, files, network) you must be as careful as possible (e.g. set IFS appropriately, disable globbing with <code>set -f</code> and quote everything). In addition remove unused scripts and examples from your Bot (e.g. everything in <code>example/</code>) and disable/remove all unused bot commands.</p>
343
-
<p>It's important to escape or remove <code>$</code> in input from user, files or network (<em>as bashbot does</em>). One of the powerful features of Unix shells is variable and command substitution using <code>${}</code> and<code>$()</code> can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped <code>$</code> is included in untrusted input (e.g. <code>$$</code> or <code>$(rm -rf /*)</code>).</p>
344
+
<p>It's important to escape or remove <code>$</code> in input from user, files or network (<em>as bashbot does</em>). One of the powerful features of Unix shells is variable and command substitution using <code>${}</code> and<code>$()</code> can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped <code>$</code> is included in untrusted input (e.g. <code>$$</code> or <code>$(rm -rf /*)</code>).</p>
344
345
<p>A powerful tool to improve your scripts is <code>shellcheck</code>. You can <ahref="https://www.shellcheck.net/">use it online</a> or <ahref="https://github.com/koalaman/shellcheck#installing">install shellcheck locally</a>. Shellcheck is used extensively in bashbot development to ensure a high code quality (e.g. it's not allowed to push changes without passing all shellcheck tests). In addition bashbot has a <ahref="doc/7_develop.md">test suite</a> to check if important functionality is working as expected.</p>
345
346
<h3>Use printf whenever possible</h3>
346
347
<p>If you're writing a script that accepts external input (e.g. from the user as arguments or the file system), you shouldn't use echo to display it. <ahref="https://unix.stackexchange.com/a/6581">Use printf whenever possible</a>.</p>
@@ -349,8 +350,9 @@ <h3>Run your Bot as a restricted user</h3>
349
350
<p><strong>Never run your Bot as root, this is the most dangerous you can do!</strong> Usually the user 'nobody' has almost no rights on Linux/Unix systems. See <ahref="doc/4_expert.md">Expert use</a> on how to run your Bot as an other user.</p>
350
351
<h3>Secure your Bot installation</h3>
351
352
<p><strong>Your Bot configuration must not be readable by other users.</strong> Everyone who can read your Bots token is able to act as your Bot and has access to all chats the Bot is in!</p>
352
-
<p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot config in<code>config.jssh</code> must be protected against other users. No one except you should have write access to the Bot files. The Bot should be restricted to have write access to<code>count.jssh</code> and <code>data-bot-bash</code> only, all other files must be write protected.</p>
353
-
<p>To set access rights for your bashbot installation to a reasonable default run<code>sudo ./bashbot.sh init</code> after every update or change to your installation directory.</p>
353
+
<p>Everyone with read access to your Bot files can extract your Bots data. Especially your Bot config in <code>config.jssh</code> must be protected against other users. No one except you should have write access to the Bot files. The Bot should be restricted to have write access to <code>count.jssh</code>, <code>data-bot-bash/</code> and <code>logs/</code> only, all other files must be write protected.</p>
354
+
<p>To set access rights for your bashbot installation to a reasonable default run <code>sudo ./bashbot.sh init</code> after every update or change to your installation directory.</p>
355
+
<p><em>Note</em>: Keep old log files in a safe place or even better delete them, they are GDPR relevant and <ahref="https://github.com/topkecleon/telegram-bot-bash/issues/174">may contain information</a> you don't want to be public.</p>
354
356
<h2>FAQ</h2>
355
357
<h3>Is this Bot insecure?</h3>
356
358
<p>Bashbot is not more (in)secure than a Bot written in another language. We have done our best to make it as secure as possible. But YOU are responsible for the bot commands you wrote and you should know about the risks ...</p>
@@ -364,8 +366,8 @@ <h3>Why Bash and not the much better xyz?</h3>
364
366
<li>no database, not event driven, not object oriented ...</li>
365
367
</ul>
366
368
<h3>Can I have the single bashbot.sh file back?</h3>
367
-
<p>At the beginning bashbot was simply the file<code>bashbot.sh</code> that you could copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.</p>
368
-
<p>Hey no problem, if you are finished with your cool bot, run<code>dev/make-standalone.sh</code> to create a stripped down version of your bot containing only 'bashbot.sh' and 'commands.sh'! For more information see <ahref="doc/7_develop.md">Create a stripped down version of your Bot</a>.</p>
369
+
<p>At the beginning bashbot was simply the file<code>bashbot.sh</code> that you could copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.</p>
370
+
<p>Hey no problem, if you are finished with your cool bot, run<code>dev/make-standalone.sh</code> to create a stripped down version of your bot containing only 'bashbot.sh' and 'commands.sh'! For more information see <ahref="doc/7_develop.md">Create a stripped down version of your Bot</a>.</p>
369
371
<h3>Can I send messages from CLI and scripts?</h3>
370
372
<p>Of course you can send messages from command line and scripts! Simply install bashbot as <ahref="#Your-really-first-bashbot-in-a-nutshell">described here</a>, send the message '/start' to set yourself as botadmin and then stop the bot with <code>./bashbot.sh stop</code>.</p>
371
373
<p>Bashbot provides some ready to use scripts for sending messages from command line in <code>bin/</code> dir, e.g. <code>send_message.sh</code>.</p>
@@ -390,6 +392,6 @@ <h3>Blocked by telegram?</h3>
390
392
<p>@Gnadelwartz</p>
391
393
<h2>That's it all guys!</h2>
392
394
<p>If you feel that there's something missing or if you found a bug, feel free to submit a pull request!</p>
Copy file name to clipboardExpand all lines: README.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,10 +11,10 @@ Elsewhere, consider it released under the [WTFPLv2](http://www.wtfpl.net/txt/cop
11
11
Linted by [#ShellCheck](https://github.com/koalaman/shellcheck)
12
12
13
13
## Prerequisites
14
-
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh) and the magic of sed.
14
+
Uses [JSON.sh](http://github.com/dominictarr/JSON.sh)/[JSON.awk](https://github.com/step-/JSON.awk) and the magic of sed.
15
15
16
16
Bashbot is written in bash. It depends on commands typically available in a Linux/Unix Environment.
17
-
For more concrete information on the common commands provided by recent versions of [coreutils](https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands), [busybox](https://en.wikipedia.org/wiki/BusyBox#Commands) or [toybox](https://landley.net/toybox/help.html), see [Developer Notes](doc/7_develop.md#common-commands).
17
+
For more information on commands provided by recent versions of [coreutils](https://en.wikipedia.org/wiki/List_of_GNU_Core_Utilities_commands), [busybox](https://en.wikipedia.org/wiki/BusyBox#Commands) or [toybox](https://landley.net/toybox/help.html), see [Developer Notes](doc/7_develop.md#common-commands).
18
18
19
19
**Note for MacOS and BSD Users:** Bashbot will not run without installing additional software as it uses modern bash and (gnu) grep/sed features. See [Install Bashbot](doc/0_install.md).
20
20
@@ -63,7 +63,8 @@ Bashbot [Documentation](https://github.com/topkecleon/telegram-bot-bash) and [Do
63
63
* Modules, addons, events
64
64
* Setup your environment
65
65
* Bashbot test suite
66
-
*[Examples Directory](examples/README.md)
66
+
*[Examples Directory](examples)
67
+
*[Webhook Example](examples/webhook)
67
68
68
69
### Your very first bashbot in a nutshell
69
70
@@ -146,7 +147,7 @@ Whenever you are processing input from untrusted sources (messages, files, netwo
146
147
from your Bot (e.g. everything in `example/`) and disable/remove all unused bot commands.
147
148
148
149
It's important to escape or remove `$` in input from user, files or network (_as bashbot does_).
149
-
One of the powerful features of Unix shells is variable and command substitution using `${}` and`$()` can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped `$` is included in untrusted input (e.g. `$$` or `$(rm -rf /*)`).
150
+
One of the powerful features of Unix shells is variable and command substitution using `${}` and`$()` can lead to remote code execution (RCE) or remote information disclosure (RID) bugs if unescaped `$` is included in untrusted input (e.g. `$$` or `$(rm -rf /*)`).
150
151
151
152
A powerful tool to improve your scripts is `shellcheck`. You can [use it online](https://www.shellcheck.net/) or
152
153
[install shellcheck locally](https://github.com/koalaman/shellcheck#installing). Shellcheck is used extensively in bashbot development
@@ -168,9 +169,11 @@ For the same reason every file your Bot can read is in danger of being disclosed
168
169
### Secure your Bot installation
169
170
**Your Bot configuration must not be readable by other users.** Everyone who can read your Bots token is able to act as your Bot and has access to all chats the Bot is in!
170
171
171
-
Everyone with read access to your Bot files can extract your Bots data. Especially your Bot config in`config.jssh` must be protected against other users. No one except you should have write access to the Bot files. The Bot should be restricted to have write access to`count.jssh` and `data-bot-bash` only, all other files must be write protected.
172
+
Everyone with read access to your Bot files can extract your Bots data. Especially your Bot config in`config.jssh` must be protected against other users. No one except you should have write access to the Bot files. The Bot should be restricted to have write access to`count.jssh`, `data-bot-bash/` and `logs/` only, all other files must be write protected.
172
173
173
-
To set access rights for your bashbot installation to a reasonable default run`sudo ./bashbot.sh init` after every update or change to your installation directory.
174
+
To set access rights for your bashbot installation to a reasonable default run `sudo ./bashbot.sh init` after every update or change to your installation directory.
175
+
176
+
*Note*: Keep old log files in a safe place or even better delete them, they are GDPR relevant and [may contain information](https://github.com/topkecleon/telegram-bot-bash/issues/174) you don't want to be public.
174
177
175
178
## FAQ
176
179
@@ -188,9 +191,9 @@ Well, that's a damn good question... maybe because I'm a Unix admin from the sto
188
191
- no database, not event driven, not object oriented ...
189
192
190
193
### Can I have the single bashbot.sh file back?
191
-
At the beginning bashbot was simply the file`bashbot.sh` that you could copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.
194
+
At the beginning bashbot was simply the file`bashbot.sh` that you could copy everywhere and run the bot. Now we have 'commands.sh', 'mycommands.sh', 'modules/*.sh' and much more.
192
195
193
-
Hey no problem, if you are finished with your cool bot, run`dev/make-standalone.sh` to create a stripped down version of your bot containing only
196
+
Hey no problem, if you are finished with your cool bot, run`dev/make-standalone.sh` to create a stripped down version of your bot containing only
194
197
'bashbot.sh' and 'commands.sh'! For more information see [Create a stripped down version of your Bot](doc/7_develop.md).
195
198
196
199
### Can I send messages from CLI and scripts?
@@ -238,4 +241,4 @@ See `mycommnds.sh.dist` for an example.
238
241
239
242
If you feel that there's something missing or if you found a bug, feel free to submit a pull request!
0 commit comments