BASHACKS(1)

NAME
bashacks - collection of useful bash functions for programmers

DESCRIPTION
Bashacks
Is a collection of Bash functions for UNIX systems, designed to simplify low-level
operations. Ideal for programmers, security analysts, and users seeking concise
commands, enhancing script readability and productivity.

SYNOPSIS
bashacks [OPTIONS] ARGUMENTS

OPTIONS

-h, --help
    Display help message and exit.

-v, --version
    Display version information and exit.

USAGE
The following Bashacks functions are available. Type the function name and press TAB
to auto-complete:
Examples of Options : bh_"TAB"
bh_asc2dec        bh_cmd_sha1       bh_hex2bin        bh_rot            bh_str2hex
bh_asciitable     bh_cmd_sha256     bh_hex2dec        bh_rot13          bh_str2hexr
bh_asmgrep        bh_cmd_sha512     bh_hex2str        bh_rotall         bh_strxor
bh_asminfo        bh_cmd_wget       bh_hexcalc        bh_secretfile     bh_unshort
bh_bin2dec        bh_dec2asc        bh_hostcalc       bh_sharefile      bh_urldecode
bh_bin2ip         bh_dec2bin        bh_ip2bin         bh_skel_c         bh_urlencode
bh_bkp            bh_dec2hex        bh_ipinfo         bh_skel_go        bh_utf8table
bh_charcalc       bh_epoch          bh_ipisblocked    bh_skel_latex     bh_wgetr
bh_cmd_disasm     bh_findmime       bh_md5rename      bh_skel_python    bh_zerostring
bh_cmd_md5        bh_hashcrack      bh_myip           bh_skel_yara      bh_zipmal
bh_cmd_sed_ext    bh_hashes         bh_replacestring  bh_str2d

CONTENTS
The Bashacks pack is organized into several subcategories for
easy location of specific functions. Each subcategory addresses
a set specific functionalities. Below the main subcategories are
available.
These subcategories help organize the package's functionalities,
making it easier for users to find and use tools wanted.

Crypto
Functions related to cryptography and hash manipulation.
    bh_hashcrack - Analyzes various types of hashes. bh_rot - Encrypts/Decrypts a string with the Caesar Cipher using n shifts to the right. bh_strxor - Calculates the exclusive OR of each character in a string with a key. For more details, see: file:///usr/share/doc/bashacks-doc/html/crypto.html

Filesystem
This section generally contains functions for file manipulation.
    bh_bkp - Performs a quick backup of the file using the current date. bh_findmime - Finds files by MIME type. bh_hashes - Generates the md5, sha1, and sha256 message digest of the file or list of files. bh_md5rename - Converts the filename to the equivalent md5 hash. bh_secretfile - Use it to compress and send files, automatically generating a password. bh_sharefile - Loads a file and provides a unique URL to access it without a password. bh_zipmal - Compresses the file in zip format with password protection. The password is "virus". For more details, see: file:///usr/share/doc/bashacks-doc/html/filesystem.html

Math
Mathematical operations functions.
    bh_bin2dec - Converts binary to decimal. bh_charcalc - Performs operations with characters (char). bh_dec2bin - Converts decimal to binary. bh_dec2hex - Converts decimal to hexadecimal. bh_hex2bi - Converts hexadecimal to binary. bh_hex2dec - Converts hexadecimal to decimal. bh_hexcalc - In the same way as bh_charcalc, however, works here with hexdigits. For more details, see: file:///usr/share/doc/bashacks-doc/html/math.html

Net
Network operations and related tools.
    bh_bin2ip - Convert a binary string into a network IP address. bh_hostcalc - Enter a network CIDR mask and determine the number of hosts. bh_ip2bin - Convert a network IP address into a binary string. bh_myip - Returns the external IP address of your network connection. bh_wgetr - Operates recursively, building on a previous instance of wget. bh_ipinfo - Queries ipinfo.io and returns basic information about an address. bh_unshort - Makes it possible to unzip a URL. bh_ipisblacklisted - Finds the IP on a blacklist, returning [T] if positive and [F] if opposite. For more details, see: file:///usr/share/doc/bashacks-doc/html/net.html

Programming
Session for the creation of facilitators for development in cli
    bh_skel_c - Generates on the standard output a "C" skeleton. bh_skel_go - Generates on the standard output a "go" skeleton. bh_skel_latex - Generates on the standard output a "LaTeX" skeleton. bh_skel_python - Generates on the standard output a "python" skeleton. bh_skel_yara - Generates on the standard output a "yara" skeleton. For more details, see: file:///usr/share/doc/bashacks-doc/html/programming.html

Reversing
Reverse engineering utilities
    bh_asmgrep - With the binary, attempts to find assembly instructions and prints 4 lines around. bh_asminfo - Displays information about assembly instructions. Internet connection is required for help. bh_replacestring - Finds and replaces occurrences of a string in the file. bh_zerostring - Replaces occurrences with zero bytes in a block or a common file. For more details, see: file:///usr/share/doc/bashacks-doc/html/reversing.html

String
Functions for string manipulation.
    bh_asc2dec - Performs the conversion of a character into its decimal equivalent. bh_asciitable - Displays the ASCII table in the terminal. bh_dec2asc - Equivalent in ASCII for decimal numbers. bh_hex2str - Converts one or more bytes into a hex string. bh_str2dec - Converts one or more bytes to their decimal equivalent. bh_str2hexr - Converts a string to its hex byte equivalent for each character (hex string). bh_str2hex - Converts a string to its hex byte equivalent for each character (hex string). bh_urldecode - Decodes strings to web standard human-readable format. bh_urlencode - Encodes strings with bh_urlencode to web standard. bh_utf8table - Displays the UTF-8 table. For more details, see: file:///usr/share/doc/bashacks-doc/html/string.html

EXAMPLES
bh_hascrack [hash string]
usage:
$ bh_hashcrack e10adc3949ba59abbe56e057f20f883e
123456
bh_rot [int] [string]
usage:
$ bh_rot 3 terra
whuud
bh_strxor [key] [string]
usage:
$ bh_strxor 15 'hack'
gnld
bh_bkp [filename]
usage:
$ bh_bkp bashacks.sh
$ ls -1
bashacks.sh
bashacks.sh.20160122
bh_findmime -[type] [directory]
usage:
$ bh_findmime -exe ~/Downloads
/home/bashacks/Downloads//binario.ex
bh_hashes [filename or list of files]
usage:
$ bh_hashes bashacks.sh
5dab37cac730088fd959f8292636fc9b bashacks.sh
38be74a4e710a3eeb24b4fa2015cea990d4eda67 bashacks.sh
587b713bb31e3bf32de0b734805c3dd247f49a14cd9e9a5f35008e4f620d3f82 bashacks.sh
bh_md5rename [filename or list of files]
usage:
$ touch ment.bin
$ bh_md5rename ment.bin
$ ls
d41d8cd98f00b204e9800998ecf8427e
bh_bin2dec [binary]
usage:
$ bh_bin2dec 1111111
bh_charcalc [char/string] [operator] [number]
usage:
$ bh_charcalc A + 2
C
$ bh_charcalc A \* 255
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
bh_dec2bin [decimal]
usage:
$ bh_dec2bin 255
11111111
bh_dec2hex [decimal]
$ bh_dec2hex 10
a
bh_hex2dec [one or more hex digit]
usage:
$ bh_hex2dec A
10
bh_hex2cal [hex digit] [operator] [hex digit]
usage:
$ bh_hex2dec A \* 2
0xa0
bh_bin2ip [binary string]
usage:
$ bh_bin2ip 00001010.00001010.00000000.00000001
10.10.0.1
bh_hostcalc [mask cidr]
usage:
$ bh_hostcalc 24
256
bh_wgetr [url]
usage:
$ bh_wgetr http://www.mentebinaria.com.br/artigos/0x1e/0x1e-maqengrevwin.html
www.mentebinaria.com.br/art 100%[==========================================>]   8.73K  --.-KB/s   in 0s
www.mentebinaria.com.br/rob 100%[==========================================>]     361  --.-KB/s   in 0s
www.mentebinaria.com.br/art 100%[==========================================>]  66.18K   132KB/s   in 0.5s
$ ls -1
www.mentebinaria.com.br
$ ls -1 www.mentebinaria.com.br/artigos/0x1e/
0x1e-maqengrevwin.html
desktop.png
bh_ipinfo [ipaddress]
usage:
$ bh_ipinfo 8.8.8.8
{
 "ip": "8.8.8.8",
 "hostname": "dns.google",
 "anycast": true,
 "city": "Mountain View",
 "region": "California",
 "country": "US",
 "loc": "37.4056,-122.0775",
 "org": "AS15169 Google LLC",
 "postal": "94043",
 "timezone": "America/Los_Angeles",
 "readme": "https://ipinfo.io/missingauth"
}
bh_ipblacklisted [ipaddress]
usage:
$ bh_ipblacklist 77.xxx.xx.xx
== 77.xxx.xx.xx ==
[F]    TALOS
[F]    Malc0de
[F]    Projecthoneypot.org
[F]    blocklist.de
[T]    Alienvault
[F]    SANS-TOPSOURCE
bh_skel_c
usage:
$ bh_skel_c
#include <stdio.h>
int main(int argc, char *argv[]) {
    return 0;
}
bh_skel_latex
usage:
$ bh_skel_latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\author{}
\title{}
bh_skel_python
usage:
$ bh_skel_python
#!/usr/bin/env python
# *-* coding: utf-8 *-*
if __name__ == '__main__':
bh_asmgrep [asm instruction] [binary path]
usage:
$ bh_asmgrep mov /bin/ls
409f2e:66 90                : xchg   %ax,%ax
409f30:80 7c 13 ff 2f       : cmpb   $0x2f,-0x1(%rbx,%rdx,1)
409f35:48 8d 42 ff          : lea    -0x1(%rdx),%rax
409f39:75 08                : jne    409f43 <__sprintf_chk@plt+0x7783>
409f3b:48 89 c2             : mov    %rax,%rdx
409f3e:48 39 d5             : cmp    %rdx,%rbp
409f41:75 ed                : jne    409f30 <__sprintf_chk@plt+0x7770>
409f43:48 83 c4 08          : add    $0x8,%rsp
--
bh_asminfo [asm instruction]
usage:
$ bh_asminfo mov
mov
|Code   |Mnemonic        |Description                                         |
|88 / r |MOV r/m8, r8    |Move r8 to r/m8                                     |
|89 / r |MOV r/m16, r16  |Move r16 to r/m16                                   |
|89 / r |MOV r/m32, r32  |Move r32 to r/m32                                   |
|8A / r |MOV r8, r/m8    |Move r/m8 to r8                                     |
|8B / r |MOV r16, r/m16  |Move r/m16 to r16                                   |
bh_replacestring [file] [string to search] [string to replace]
usage:
$ hexdump -C MB_DEV
00000690  2e 00 54 00 58 00 54 00  2e 00 00 00 73 00 77 00  |..T.X.T.....s.w.|
000006a0  e5 45 53 54 45 54 7e 31  53 57 58 20 00 65 a1 9b  |.ESTET~1SWX .e..|
000006b0  8b 54 8b 54 00 00 a1 9b  8b 54 00 00 00 00 00 00  |.T.T.....T......|
000006c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00005e00  4d 65 6e 74 65 42 69 6e  61 72 69 61 0a 00 00 00  |MenteBinaria....|
00005e10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
bh_zerostring [file] [string to replace]
usage:
# hexdump -C MB_DEV
00005860  41 4d 00 42 00 2d 00 66  00 69 00 0f 00 a1 6c 00  |AM.B.-.f.i....l.|
00005870  65 00 2e 00 74 00 78 00  74 00 00 00 00 00 ff ff  |e...t.x.t.......|
00005880  4d 42 2d 46 49 4c 45 20  54 58 54 20 00 41 26 be  |MB-FILE TXT .A&.|
00005890  69 54 69 54 00 00 26 be  69 54 05 00 1b 00 00 00  |iTiT..&.iT......|
bh_asc2dec [char]
usage:
$  bh_asc2dec a
97
bh_dec2asc [decimal]
usage:
$ bh_dec2asc 65
A
bh_hex2str [hex string]
usage:
$ bh_hex2str '72 6f 63 6b'
rock
bh_str2hex [-x] [-0x] [-c] [string]
usage:
$ bh_str2hex 'Fernando'
46 65 72 6e 61 6e 64 6f
$ bh_str2hex -0x 'Fernado'
0x46 0x65 0x72 0x6e 0x61 0x6e 0x64 0x6f
bh_urldecode [encoded string]
usage:
$ bh_urlencode '/zzz!@.#'
%2fzzz%21%40%2e%23

SEE ALSO
For more information about bashacks visit: https://github.com/merces/bashacks/tree/master/doc/source

AUTHOR
Developed by Fernando Merces <contato@mentebinaria.com.br>

This manual page was written by Josenison Ferreira da Silva <nilsonfsilva@hotmail.com>
for the Debian project (but may be used by others).