├── .gitattributes
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── doc
├── bashacks.1
├── codestyle.md
└── source
│ ├── conf.py
│ ├── crypto.rst
│ ├── filesystem.rst
│ ├── index.rst
│ ├── install.rst
│ ├── math.rst
│ ├── net.rst
│ ├── programming.rst
│ ├── reversing.rst
│ └── string.rst
└── src
├── crypto
├── bh_rot.sh
├── bh_rotall.sh
└── bh_strxor.sh
├── filesystem
├── bh_bkp.sh
├── bh_findmime.sh
├── bh_hashes.sh
├── bh_md5rename.sh
├── bh_secretfile.sh
├── bh_sharefile.sh
└── bh_zipmal.sh
├── internal
├── bashacks.sh
└── bootstrap.sh
├── math
├── bh_bin2dec.sh
├── bh_charcalc.sh
├── bh_dec2bin.sh
├── bh_dec2hex.sh
├── bh_hex2bin.sh
├── bh_hex2dec.sh
└── bh_hexcalc.sh
├── misc
└── bh_epoch.sh
├── net
├── bh_bin2ip.sh
├── bh_hostcalc.sh
├── bh_ip2bin.sh
├── bh_ipinfo.sh
├── bh_ipisblocked.sh
├── bh_myip.sh
├── bh_unshort.sh
└── bh_wgetr.sh
├── programming
├── bh_skel_c.sh
├── bh_skel_go.sh
├── bh_skel_latex.sh
├── bh_skel_python.sh
└── bh_skel_yara.sh
├── reversing
├── bh_asmgrep.sh
├── bh_asminfo.sh
├── bh_replacestring.sh
└── bh_zerostring.sh
└── strings
├── bh_asciitable.sh
├── bh_dec2asc.sh
├── bh_hex2str.sh
├── bh_str2dec.sh
├── bh_str2hex.sh
├── bh_str2hexr.sh
├── bh_urldecode.sh
├── bh_urlencode.sh
└── bh_utf8table.sh
/.gitattributes:
--------------------------------------------------------------------------------
1 | text eol=lf
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bashacks.sh
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SRC = `find src/ -type f -name 'bh_*.sh' | LC_ALL=C sort`
2 | OUTFILE = bashacks.sh
3 | BASHRCFILE = ~/.profile
4 | BASHACKS = `pwd`/$(OUTFILE)
5 |
6 | all:
7 | cat src/internal/bootstrap.sh > $(OUTFILE)
8 | for file in $(SRC); do \
9 | cat $$file >> $(OUTFILE); \
10 | echo >> $(OUTFILE); \
11 | done
12 | tr -d \\r < $(OUTFILE) > $(OUTFILE).tmp
13 | mv $(OUTFILE).tmp $(OUTFILE)
14 |
15 | install:
16 | [ -e $(OUTFILE) ] && \
17 | echo -e "\n[ -e $(BASHACKS) ] && . $(BASHACKS)" >> $(BASHRCFILE) \
18 | || \
19 | echo -e "$(OUTFILE) not found. Try: make\n"
20 |
21 | clean:
22 | rm -f bashacks.sh
23 |
24 | uninstall:
25 | sed -i .bak "/bashacks\.sh/d" $(BASHRCFILE)
26 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # bashacks
2 |
3 | ## What?
4 |
5 | bashacks is as a collection of bash functions most likely useful for programmers, security analysts, and general users that need some low level type of operations.
6 |
7 | In fact, there is nothing really new in bashacks as all functions are written using existing software in UNIX-like systems. However, it allows you to use shorter commands to achieve tasks that'd commonly require multiple commands.
8 |
9 | ## Requirements
10 |
11 | * bash >= 4
12 | * bc
13 | * binutils
14 | * coreutils
15 | * curl
16 | * file
17 | * grep
18 | * hexdump
19 | * html2text
20 | * perl
21 | * sed
22 | * wget
23 | * xxd
24 | * zip
25 |
26 | ## Installation
27 |
28 | Use the *make* command to generate a single file containing all functions and add it to your ```/etc/bash.bashrc``` file:
29 |
30 | make
31 | make install
32 |
33 | That's all. You can now check the available functions from command line by typing *bh_* and pressing TAB.
34 |
35 | ## Documentation
36 |
37 | There's some [here](https://bashacks.readthedocs.io/), but it is outdated. PRs are welcome!
38 |
39 | ## Usage
40 |
41 | What time is now in Epoch?
42 |
43 | $ bh_epoch
44 | 1522324129
45 |
46 | Alphabetically add 4 to 'f'
47 |
48 | $ bh_charcalc f + 4
49 | j
50 |
51 | Check my external IP address
52 |
53 | $ bh_myip
54 | 177.212.113.13
55 |
56 | Create a basic C program skeleton
57 |
58 | $ bh_skel_c > hello.c
59 | $ cat hello.c
60 | #include
61 |
62 | int main(int argc, char *argv[]) {
63 |
64 |
65 | return 0;
66 | }
67 |
68 | Calculate common checksums for files
69 |
70 | $ bh_hashes /bin/ip*
71 | 387478f58a0669173fb6557d392a58e9 /bin/ip
72 | 1dd0f3b100bd6efc4664da0cdefff801d7d2efd8 /bin/ip
73 | 1d418ae3a767280c7fc6026a25e5bb9774c0e8afc7b3387b547765b62cbe578f /bin/ip
74 | 78868acd29e4a33194fb786f6589d3d1 /bin/ipcmk
75 | 8c22a129ff4b5748cc62222a93ba8471d7fdce19 /bin/ipcmk
76 | 34a068d7f85e85746b3fc98502fa96a734cc51f3a9d49cad92911e8f239bd9c9 /bin/ipcmk
77 | 69c2bedc20e77c039912c9d5e7af33db /bin/ipcrm
78 | 7992a936b28359d7f087a448d2b8a2418ef4f112 /bin/ipcrm
79 | cded383eb3b74467409c1731c2804350fe3d1123bdac7304c1c6f3af9e7976f7 /bin/ipcrm
80 | 499f17765c0aa55ac99739c9bcac1d0c /bin/ipcs
81 | c476949e77ef8710398fd8ec4f78c8cf1d76a420 /bin/ipcs
82 | 33c77a5b625f4de919f55dc24207645d219a2fde2e0b92be27c5cda8c662cd72 /bin/ipcs
83 | 6a738c5c2506f7e87c9458e0c3df378f /bin/iptables-xml
84 | ba97af2e429aca6beb5a2b8861e370bbf874dee9 /bin/iptables-xml
85 | cb8c10461da5247e8d6d63a123ba563df95ae1e78f29e1717eb8bb02c2ca045b /bin/iptables-xml
86 |
87 | Find files by MIME type (ignores file extension):
88 |
89 | $ bh_findmime -elf /bin | head
90 | /bin/[
91 | /bin/addpart
92 | /bin/appres
93 | /bin/apt
94 | /bin/apt-cache
95 | /bin/apt-cdrom
96 | /bin/apt-config
97 | /bin/apt-extracttemplates
98 | /bin/apt-ftparchive
99 | /bin/apt-get
100 |
101 | You could pipe the results to xargs in order to calculate checksums quickly:
102 |
103 | $ bh_findmime -pe ~/Downloads/ | xargs shasum
104 | d9e49c4209087170e36cbef689d96240d736cf3b /Users/menteb/Downloads/CSCWCNG.dll
105 | 50dfeea02e89f41caf52df152c7cb923c667bffc /Users/menteb/Downloads/Receitanet-1.10.exe
106 | 86a5f89d43ab11456fb817aeceb14b83cc6c2608 /Users/menteb/Downloads/Xojo2017r3Setup.exe.opdownload
107 |
108 | Convert string to hex in different output formats
109 |
110 | $ bh_str2hex mentebinaria
111 | 6d 65 6e 74 65 62 69 6e 61 72 69 61
112 |
113 | $ bh_str2hex -x mentebinaria
114 | \x6d\x65\x6e\x74\x65\x62\x69\x6e\x61\x72\x69\x61
115 |
116 | $ bh_str2hex -c mentebinaria
117 | { 0x6d, 0x65, 0x6e, 0x74, 0x65, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x69, 0x61 }
118 |
119 | There is very basic error handling in bashacks. If a function does not receive the arguments it needs, it justs returns `1`.
120 |
121 | There's much more. Install it and see for yourself. :)
122 |
123 | ## Changelog
124 |
125 | ### bashacks 1.5 - 2024 - soon
126 |
127 | * New name: bashacks
128 | * Bugs fixed.
129 | * New cache engine at $HOME/.bashacks/cache used by internet dependent functions like `bh_asminfo` and `bh_hashcrack`.
130 | * New functions:
131 | * `bh_asminfo` - details an Assembly x86 instruction.
132 | * `bh_epoch` - converts an Epoch date to its human-readable equivalent.
133 | * `bh_findmime` - finds files by their MIME-type.
134 | * `bh_hostcalc` - returns the total hosts number for an IPv4 subnet.
135 | * `bh_md5rename` - renames files to their MD5 hash.
136 | * `bh_sharefile` - upload a file to file.io and returns a download link that only works once.
137 | * `bh_skel_c` - outputs a blank C source file skeleton.
138 | * `bh_skel_python` - outputs a blank Python script skeleton.
139 | * `bh_skel_yara` - outputs a simple Yara rule skeleton.
140 | * `bh_str2hexr` - converts a string to its reversed hexadecimal equivalent.
141 | * `bh_unshort` - gives the real URL behind shortened links.
142 | * `bh_urlencode` - decodes an URL-encoded string.
143 | * `bh_wgetr` - site mirroring with random interval between resquests and custom User-Agent.
144 | * `bh_zerostring` - fill a string with nullbytes in a binary file.
145 | * `bh_zipmal` - zip files with 'infected' password.
146 | * `bh_ipblocked` - checks if an IP address is blocked by a few security vendors.
147 | * `bh_skel_latex` - outputs a LaTeX template.
148 | * Removed functions:
149 | * `bh_intel` is not needed anymore.
150 | * `bh_asc2dec` you can get the same results with `bh_str2dec`.
151 | * `bh_asc2hex` result is easily achieved with `echo a | hd`.
152 | * `bh_hashcrack` the service previously used went down again, and this is hard to maintain.
153 |
154 | ### hack-functions 1.4 - February, 27 2012
155 |
156 | * new function: `bh_charcalc` - performs math with characters.
157 | * new function: `bh_intel` - set Intel syntax for disassembling.
158 | * new function: `bh_rotall` - simultaneous ROT for strings (thanks to @laerciomasalla for suggesting it).
159 | * created reference guide in Portuguese.
160 | * `bh_hexcalc` now supports the four basic math operations and the result is prefixed with `0x`.
161 | * `bh_str2hex` and `hex2str` now support the prefixes `0x`, `\x`, with or without spaces, and C-style arrays.
162 |
163 | ### hack-functions 1.2 - February, 24 2012
164 |
165 | * new functions: `bh_bin2dec` and `bh_asc2hex`.
166 | * added Intel syntax by default for gdb and objdump.
167 | * curl gets replaced by wget in `bh_unmd5`.
168 | * code optimization in many functions.
169 |
170 | ### hack-functions 1.0 - February, 24 2012
171 |
172 | * first public release containing 20 functions.
173 |
174 | ## Known Bugs
175 |
176 | ### String escape
177 |
178 | In some string functions you have to escape special characters because bash will try to
179 | interpret them. See the following example using bh_strxor function:
180 |
181 | $ bh_strxor 0x41 fernando
182 | '$3/ /%.
183 |
184 | $ bh_strxor 0x41 "'\$3/ /%." # string between double quotes and dollar sign escaped
185 | fernando
186 |
187 | ### Zsh support
188 |
189 | Many bashacks functions use the word splitting feature from bash, so they don't work by default in Zsh. However, you can configure Zsh to perform word splitting with the following command:
190 |
191 | $ setopt sh_word_split
192 |
193 | Then things should work.
194 |
--------------------------------------------------------------------------------
/doc/bashacks.1:
--------------------------------------------------------------------------------
1 | .TH BASHACKS 1 "November 2023" "bashacks 1.5" "User Commands"
2 |
3 | .SH NAME
4 | bashacks \- collection of useful bash functions for programmers
5 |
6 | .SH DESCRIPTION
7 | .B Bashacks
8 | .nf
9 | .fam C
10 | Is a collection of Bash functions for UNIX systems, designed to simplify low-level
11 | operations. Ideal for programmers, security analysts, and users seeking concise
12 | commands, enhancing script readability and productivity.
13 | .fam T
14 | .fi
15 | .SH SYNOPSIS
16 | .B bashacks
17 | [\fIOPTIONS\fP] \fIARGUMENTS\fP
18 |
19 | .SH OPTIONS
20 | .TP
21 | .B \-h, \-\-help
22 | Display help message and exit.
23 |
24 | .TP
25 | .B \-v, \-\-version
26 | Display version information and exit.
27 |
28 | .SH USAGE
29 | .nf
30 | .fam C
31 | The following Bashacks functions are available. Type the function name and press TAB
32 | to auto-complete:
33 | .B "Examples of Options": bh_"TAB"
34 | \fBbh_asc2dec\fR \fBbh_cmd_sha1\fR \fBbh_hex2bin\fR \fBbh_rot\fR \fBbh_str2hex\fR
35 | \fBbh_asciitable\fR \fBbh_cmd_sha256\fR \fBbh_hex2dec\fR \fBbh_rot13\fR \fBbh_str2hexr\fR
36 | \fBbh_asmgrep\fR \fBbh_cmd_sha512\fR \fBbh_hex2str\fR \fBbh_rotall\fR \fBbh_strxor\fR
37 | \fBbh_asminfo\fR \fBbh_cmd_wget\fR \fBbh_hexcalc\fR \fBbh_secretfile\fR \fBbh_unshort\fR
38 | \fBbh_bin2dec\fR \fBbh_dec2asc\fR \fBbh_hostcalc\fR \fBbh_sharefile\fR \fBbh_urldecode\fR
39 | \fBbh_bin2ip\fR \fBbh_dec2bin\fR \fBbh_ip2bin\fR \fBbh_skel_c\fR \fBbh_urlencode\fR
40 | \fBbh_bkp\fR \fBbh_dec2hex\fR \fBbh_ipinfo\fR \fBbh_skel_go\fR \fBbh_utf8table\fR
41 | \fBbh_charcalc\fR \fBbh_epoch\fR \fBbh_ipisblocked\fR \fBbh_skel_latex\fR \fBbh_wgetr\fR
42 | \fBbh_cmd_disasm\fR \fBbh_findmime\fR \fBbh_md5rename\fR \fBbh_skel_python\fR \fBbh_zerostring\fR
43 | \fBbh_cmd_md5\fR \fBbh_hashcrack\fR \fBbh_myip\fR \fBbh_skel_yara\fR \fBbh_zipmal\fR
44 | \fBbh_cmd_sed_ext\fR \fBbh_hashes\fR \fBbh_replacestring\fR \fBbh_str2dec\fR
45 | .fam T
46 | .fi
47 |
48 | .SH "CONTENTS
49 | .nf
50 | .fam C
51 | The Bashacks pack is organized into several subcategories for
52 | easy location of specific functions. Each subcategory addresses
53 | a set specific functionalities. Below the main subcategories are
54 | available.
55 |
56 | These subcategories help organize the package's functionalities,
57 | making it easier for users to find and use tools wanted.
58 | .fam T
59 | .fi
60 |
61 | .TP 2
62 | .SH "Crypto"
63 | Functions related to cryptography and hash manipulation.
64 |
65 | \fBbh_hashcrack\fR - Analyzes various types of hashes.
66 |
67 | \fBbh_rot\fR - Encrypts/Decrypts a string with the Caesar Cipher using n shifts to the right.
68 |
69 | \fBbh_strxor\fR - Calculates the exclusive OR of each character in a string with a key.
70 |
71 | \fBFor more details, see:\fR
72 | .UR file:///usr/share/doc/bashacks-doc/html/crypto.html
73 | .UE
74 |
75 |
76 | .TP 2
77 | .SH "Filesystem"
78 | This section generally contains functions for file manipulation.
79 |
80 | \fBbh_bkp\fR - Performs a quick backup of the file using the current date.
81 |
82 | \fBbh_findmime\fR - Finds files by MIME type.
83 |
84 | \fBbh_hashes\fR - Generates the md5, sha1, and sha256 message digest of the file or list of files.
85 |
86 | \fBbh_md5rename\fR - Converts the filename to the equivalent md5 hash.
87 |
88 | \fBbh_secretfile\fR - Use it to compress and send files, automatically generating a password.
89 |
90 | \fBbh_sharefile\fR - Loads a file and provides a unique URL to access it without a password.
91 |
92 | \fBbh_zipmal\fR - Compresses the file in zip format with password protection. The password is "virus".
93 |
94 | \fBFor more details, see:\fR
95 | .UR file:///usr/share/doc/bashacks-doc/html/filesystem.html
96 | .UE
97 |
98 |
99 | .TP 2
100 | .SH "Math"
101 | Mathematical operations functions.
102 |
103 | \fBbh_bin2dec\fR - Converts binary to decimal.
104 |
105 | \fBbh_charcalc\fR - Performs operations with characters (char).
106 |
107 | \fBbh_dec2bin\fR - Converts decimal to binary.
108 |
109 | \fBbh_dec2hex\fR - Converts decimal to hexadecimal.
110 |
111 | \fBbh_hex2bi\fR - Converts hexadecimal to binary.
112 |
113 | \fBbh_hex2dec\fR - Converts hexadecimal to decimal.
114 |
115 | \fBbh_hexcalc\fR - In the same way as \fBbh_charcalc\fR, however, works here with hexdigits.
116 |
117 | \fBFor more details, see:\fR
118 | .UR file:///usr/share/doc/bashacks-doc/html/math.html
119 | .UE
120 |
121 |
122 | .TP 2
123 | .SH "Net"
124 | Network operations and related tools.
125 |
126 | \fBbh_bin2ip\fR - Convert a binary string into a network IP address.
127 |
128 | \fBbh_hostcalc\fR - Enter a network CIDR mask and determine the number of hosts.
129 |
130 | \fBbh_ip2bin\fR - Convert a network IP address into a binary string.
131 |
132 | \fBbh_myip\fR - Returns the external IP address of your network connection.
133 |
134 | \fBbh_wgetr\fR - Operates recursively, building on a previous instance of wget.
135 |
136 | \fBbh_ipinfo\fR - Queries ipinfo.io and returns basic information about an address.
137 |
138 | \fBbh_unshort\fR - Makes it possible to unzip a URL.
139 |
140 | \fBbh_ipisblacklisted\fR - Finds the IP on a blacklist, returning [T] if positive and [F] if opposite.
141 |
142 | \fBFor more details, see:\fR
143 | .UR file:///usr/share/doc/bashacks-doc/html/net.html
144 | .UE
145 |
146 |
147 | .TP 2
148 | .SH "Programming"
149 | Session for the creation of facilitators for development in cli
150 |
151 | \fBbh_skel_c\fR - Generates on the standard output a "C" skeleton.
152 |
153 | \fBbh_skel_go\fR - Generates on the standard output a "go" skeleton.
154 |
155 | \fBbh_skel_latex\fR - Generates on the standard output a "LaTeX" skeleton.
156 |
157 | \fBbh_skel_python\fR - Generates on the standard output a "python" skeleton.
158 |
159 | \fBbh_skel_yara\fR - Generates on the standard output a "yara" skeleton.
160 |
161 | \fBFor more details, see:\fR
162 | .UR file:///usr/share/doc/bashacks-doc/html/programming.html
163 | .UE
164 |
165 |
166 | .TP 2
167 | .SH "Reversing"
168 | Reverse engineering utilities
169 |
170 | \fBbh_asmgrep\fR - With the binary, attempts to find assembly instructions and prints 4 lines around.
171 |
172 | \fBbh_asminfo\fR - Displays information about assembly instructions. Internet connection is required for help.
173 |
174 | \fBbh_replacestring\fR - Finds and replaces occurrences of a string in the file.
175 |
176 | \fBbh_zerostring\fR - Replaces occurrences with zero bytes in a block or a common file.
177 |
178 | \fBFor more details, see:\fR
179 | .UR file:///usr/share/doc/bashacks-doc/html/reversing.html
180 | .UE
181 |
182 |
183 | .TP 2
184 | .SH "String"
185 | Functions for string manipulation.
186 |
187 | \fBbh_asc2dec\fR - Performs the conversion of a character into its decimal equivalent.
188 |
189 | \fBbh_asciitable\fR - Displays the ASCII table in the terminal.
190 |
191 | \fBbh_dec2asc\fR - Equivalent in ASCII for decimal numbers.
192 |
193 | \fBbh_hex2str\fR - Converts one or more bytes into a hex string.
194 |
195 | \fBbh_str2dec\fR - Converts one or more bytes to their decimal equivalent.
196 |
197 | \fBbh_str2hexr\fR - Converts a string to its hex byte equivalent for each character (hex string).
198 |
199 | \fBbh_str2hex\fR - Converts a string to its hex byte equivalent for each character (hex string).
200 |
201 | \fBbh_urldecode\fR - Decodes strings to web standard human-readable format.
202 |
203 | \fBbh_urlencode\fR - Encodes strings with bh_urlencode to web standard.
204 |
205 | \fBbh_utf8table\fR - Displays the UTF-8 table.
206 |
207 | \fBFor more details, see:\fR
208 | .UR file:///usr/share/doc/bashacks-doc/html/string.html
209 | .UE
210 |
211 |
212 | .SH EXAMPLES
213 | .nf
214 | .fam C
215 | \fBbh_hascrack\fR [hash string]
216 | usage:
217 | $ bh_hashcrack e10adc3949ba59abbe56e057f20f883e
218 | 123456
219 |
220 |
221 | \fBbh_rot\fR [int] [string]
222 | usage:
223 | $ bh_rot 3 terra
224 | whuud
225 |
226 |
227 | \fBbh_strxor\fR [key] [string]
228 | usage:
229 | $ bh_strxor 15 'hack'
230 | gnld
231 |
232 |
233 | \fBbh_bkp\fR [filename]
234 | usage:
235 | $ bh_bkp bashacks.sh
236 | $ ls -1
237 | bashacks.sh
238 | bashacks.sh.20160122
239 |
240 |
241 | \fBbh_findmime\fR -[type] [directory]
242 | usage:
243 | $ bh_findmime -exe ~/Downloads
244 | /home/bashacks/Downloads//binario.ex
245 |
246 |
247 | \fBbh_hashes\fR [filename or list of files]
248 | usage:
249 | $ bh_hashes bashacks.sh
250 | 5dab37cac730088fd959f8292636fc9b bashacks.sh
251 | 38be74a4e710a3eeb24b4fa2015cea990d4eda67 bashacks.sh
252 | 587b713bb31e3bf32de0b734805c3dd247f49a14cd9e9a5f35008e4f620d3f82 bashacks.sh
253 |
254 |
255 | \fBbh_md5rename\fR [filename or list of files]
256 | usage:
257 | $ touch ment.bin
258 | $ bh_md5rename ment.bin
259 | $ ls
260 | d41d8cd98f00b204e9800998ecf8427e
261 |
262 |
263 | \fBbh_bin2dec\fR [binary]
264 | usage:
265 | $ bh_bin2dec 1111111
266 |
267 |
268 | \fBbh_charcalc\fR [char/string] [operator] [number]
269 | usage:
270 | $ bh_charcalc A + 2
271 | C
272 |
273 | $ bh_charcalc A \\* 255
274 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
275 |
276 |
277 | \fBbh_dec2bin\fR [decimal]
278 | usage:
279 | $ bh_dec2bin 255
280 | 11111111
281 |
282 |
283 | \fBbh_dec2hex\fR [decimal]
284 | $ bh_dec2hex 10
285 | a
286 |
287 |
288 | \fBbh_hex2dec\fR [one or more hex digit]
289 | usage:
290 | $ bh_hex2dec A
291 | 10
292 |
293 |
294 | \fBbh_hex2cal\fR [hex digit] [operator] [hex digit]
295 | usage:
296 | $ bh_hex2dec A \\* 2
297 | 0xa0
298 |
299 |
300 | \fBbh_bin2ip\fR [binary string]
301 | usage:
302 | $ bh_bin2ip 00001010.00001010.00000000.00000001
303 | 10.10.0.1
304 |
305 |
306 | \fBbh_hostcalc\fR [mask cidr]
307 | usage:
308 | $ bh_hostcalc 24
309 | 256
310 |
311 |
312 | \fBbh_wgetr\fR [url]
313 | usage:
314 | $ bh_wgetr http://www.mentebinaria.com.br/artigos/0x1e/0x1e-maqengrevwin.html
315 | www.mentebinaria.com.br/art 100%[==========================================>] 8.73K --.-KB/s in 0s
316 | www.mentebinaria.com.br/rob 100%[==========================================>] 361 --.-KB/s in 0s
317 | www.mentebinaria.com.br/art 100%[==========================================>] 66.18K 132KB/s in 0.5s
318 | $ ls -1
319 | www.mentebinaria.com.br
320 | $ ls -1 www.mentebinaria.com.br/artigos/0x1e/
321 | 0x1e-maqengrevwin.html
322 | desktop.png
323 |
324 |
325 | \fBbh_ipinfo\fR [ipaddress]
326 | usage:
327 | $ bh_ipinfo 8.8.8.8
328 | {
329 | "ip": "8.8.8.8",
330 | "hostname": "dns.google",
331 | "anycast": true,
332 | "city": "Mountain View",
333 | "region": "California",
334 | "country": "US",
335 | "loc": "37.4056,-122.0775",
336 | "org": "AS15169 Google LLC",
337 | "postal": "94043",
338 | "timezone": "America/Los_Angeles",
339 | "readme": "https://ipinfo.io/missingauth"
340 | }
341 |
342 |
343 | \fBbh_ipblacklisted\fR [ipaddress]
344 | usage:
345 | $ bh_ipblacklist 77.xxx.xx.xx
346 | == 77.xxx.xx.xx ==
347 | [F] TALOS
348 | [F] Malc0de
349 | [F] Projecthoneypot.org
350 | [F] blocklist.de
351 | [T] Alienvault
352 | [F] SANS-TOPSOURCE
353 |
354 |
355 | \fBbh_skel_c\fR
356 | usage:
357 | $ bh_skel_c
358 | #include
359 |
360 | int main(int argc, char *argv[]) {
361 |
362 | return 0;
363 | }
364 |
365 |
366 | \fBbh_skel_latex\fR
367 | usage:
368 | $ bh_skel_latex
369 | \edocumentclass{article}
370 |
371 | \eusepackage[english]{babel}
372 | \eusepackage[utf8]{inputenc}
373 | \eusepackage[margin=1in]{geometry}
374 |
375 | \eauthor{}
376 | \etitle{}
377 |
378 |
379 | \fBbh_skel_python\fR
380 | usage:
381 | $ bh_skel_python
382 | #!/usr/bin/env python
383 | # *-* coding: utf-8 *-*
384 |
385 | if __name__ == '__main__':
386 |
387 |
388 | \fBbh_asmgrep\fR [asm instruction] [binary path]
389 | usage:
390 | $ bh_asmgrep mov /bin/ls
391 |
392 | 409f2e:66 90 : xchg %ax,%ax
393 | 409f30:80 7c 13 ff 2f : cmpb $0x2f,-0x1(%rbx,%rdx,1)
394 | 409f35:48 8d 42 ff : lea -0x1(%rdx),%rax
395 | 409f39:75 08 : jne 409f43 <__sprintf_chk@plt+0x7783>
396 | 409f3b:48 89 c2 : mov %rax,%rdx
397 | 409f3e:48 39 d5 : cmp %rdx,%rbp
398 | 409f41:75 ed : jne 409f30 <__sprintf_chk@plt+0x7770>
399 | 409f43:48 83 c4 08 : add $0x8,%rsp
400 | --
401 |
402 |
403 | \fBbh_asminfo\fR [asm instruction]
404 | usage:
405 | $ bh_asminfo mov
406 | mov
407 | |Code |Mnemonic |Description |
408 | |88 / r |MOV r/m8, r8 |Move r8 to r/m8 |
409 | |89 / r |MOV r/m16, r16 |Move r16 to r/m16 |
410 | |89 / r |MOV r/m32, r32 |Move r32 to r/m32 |
411 | |8A / r |MOV r8, r/m8 |Move r/m8 to r8 |
412 | |8B / r |MOV r16, r/m16 |Move r/m16 to r16 |
413 |
414 |
415 | \fBbh_replacestring\fR [file] [string to search] [string to replace]
416 | usage:
417 | $ hexdump -C MB_DEV
418 |
419 | 00000690 2e 00 54 00 58 00 54 00 2e 00 00 00 73 00 77 00 |..T.X.T.....s.w.|
420 | 000006a0 e5 45 53 54 45 54 7e 31 53 57 58 20 00 65 a1 9b |.ESTET~1SWX .e..|
421 | 000006b0 8b 54 8b 54 00 00 a1 9b 8b 54 00 00 00 00 00 00 |.T.T.....T......|
422 | 000006c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
423 | *
424 | 00005e00 4d 65 6e 74 65 42 69 6e 61 72 69 61 0a 00 00 00 |MenteBinaria....|
425 | 00005e10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
426 |
427 |
428 | \fBbh_zerostring\fR [file] [string to replace]
429 | usage:
430 | # hexdump -C MB_DEV
431 |
432 | 00005860 41 4d 00 42 00 2d 00 66 00 69 00 0f 00 a1 6c 00 |AM.B.-.f.i....l.|
433 | 00005870 65 00 2e 00 74 00 78 00 74 00 00 00 00 00 ff ff |e...t.x.t.......|
434 | 00005880 4d 42 2d 46 49 4c 45 20 54 58 54 20 00 41 26 be |MB-FILE TXT .A&.|
435 | 00005890 69 54 69 54 00 00 26 be 69 54 05 00 1b 00 00 00 |iTiT..&.iT......|
436 |
437 |
438 | \fBbh_asc2dec\fR [char]
439 | usage:
440 | $ bh_asc2dec a
441 | 97
442 |
443 |
444 | \fBbh_dec2asc\fR [decimal]
445 | usage:
446 | $ bh_dec2asc 65
447 | A
448 |
449 |
450 | \fBbh_hex2str\fR [hex string]
451 | usage:
452 | $ bh_hex2str '72 6f 63 6b'
453 | rock
454 |
455 |
456 | \fBbh_str2hex\fR [-x] [-0x] [-c] [string]
457 | usage:
458 | $ bh_str2hex 'Fernando'
459 | 46 65 72 6e 61 6e 64 6f
460 | $ bh_str2hex -0x 'Fernado'
461 | 0x46 0x65 0x72 0x6e 0x61 0x6e 0x64 0x6f
462 |
463 |
464 | \fBbh_urldecode\fR [encoded string]
465 | usage:
466 | $ bh_urlencode '/zzz!@.#'
467 | %2fzzz%21%40%2e%23
468 | .fam T
469 | .fi
470 |
471 | .SH SEE ALSO
472 | For more information about bashacks visit:
473 | https://github.com/merces/bashacks/tree/master/doc/source
474 |
475 | .SH AUTHOR
476 | .fam C
477 | .nf
478 | Developed by Fernando Merces
479 | .PP
480 | This manual page was written by Josenison Ferreira da Silva
481 | for the Debian project (but may be used by others).
482 | .fam T
483 | .fi
484 |
--------------------------------------------------------------------------------
/doc/codestyle.md:
--------------------------------------------------------------------------------
1 | # Bashacks Code Style
2 |
3 | See this document as a source of recommendations and try permform this.
4 |
5 | *Have fun in your code!!!* ;)
6 |
7 | ## General considerations
8 | * Limit your code in **78 col**
9 | * Avoid using more than one command per line.
10 | * All interaction with its function must be by **parameters** or **file** reading.
11 | * Keep your code indented.
12 | * All development must be the develop branch.
13 |
14 | ## Functions
15 | * The name of all functions must be prefixed with **bh_**.
16 | * Should be alphanumeric ([a-z0-9]){1,20}, *no limit your mind*.
17 | * Do not use accent, hyphen, punctuation.
18 | * The name of all functions must be **english**.
19 | * All functions should return True 0 (zero) or False 1 (one), except cases like *bh_asciitable* e *bh_str2hex*.
20 | * To document their function use the man page, do not create help.
21 | * Always validate the arguments sent to a function, validate that the information is expected mode.
22 |
23 | ###### Correct:
24 | ```bash
25 | bh_isreversedns() {
26 | return 0
27 | }
28 | ```
29 |
30 | ###### Incorrect
31 | ```bash
32 | function bh_isreversedns {
33 | return 0
34 | }
35 | ```
36 |
37 | ###### Incorrect
38 | ```bash
39 | bh_isreversedns()
40 | {
41 | return 0
42 | }
43 | ```
44 |
45 | ## Variables
46 |
47 | * Only use local variables. Always use the command **'local'** always use at the beginning of the function.
48 | * Local variables with attributes, only use one per line.
49 | * Only lowercase letters should compose the name of the variable [a-z0-9]+
50 | * All variables must be declared and initiated.
51 | * To work with variable use **"$"** dollar sign **"$nome"** except array.
52 | * Whenever possible use **"double quotes"** or **'single quotes'** to protect the contents of the variable
53 |
54 |
55 | ```bash
56 | local stname=""
57 | local arrayobject=()
58 | local number=0
59 | ```
60 | ###### Corret:
61 | ```bash
62 | bh_isreversedns() {
63 | local ipaddress="$1"
64 | local fqdn="$2"
65 | local status=1
66 |
67 | return 0
68 | }
69 | ```
70 |
71 | ## code block
72 |
73 | * When using commands with many parameters use **backslash** to keep readable code.
74 | * We Don't want to be boring in the use of **'if/then/else/fi'**, there are several ways of doing only want common sense.
75 | * Avoid using unnecessary blank spacing, use only one of each line.
76 | * To comment of your code use the character **'#'** 'be clear to do'.
77 | * Don't use apostrophe, use **"$(...)"**
78 | * Make sure that the outpu isn't committed to its validations, use the **/dev/null** always that necessary.
79 | * Always that use pipe uses **backslash** and send the pip for next line, with this we can identify which part of code is on the next line.
80 | * Use one row for each keyword **'if/then/else/fi'** **'for/do/done'** **'while/do/done'**
81 | * Avoid using **Eval** **(Avoid)**
82 |
83 | ###### Example
84 | ```bash
85 | for i in {1..5}
86 | do
87 | echo $i
88 | done
89 | ```
90 | ```bash
91 | while read foo
92 | do
93 | echo "$foo"
94 | done < file.txt
95 | ```
96 |
97 | ###### Correct:
98 | ```bash
99 | bh_isreversedns() {
100 | local ipaddress="$1"
101 | local fqdn="$2"
102 | local status=1
103 |
104 | # if not informed required arguments returning false.
105 | [ $# -ne 2 ] && return $status
106 |
107 | # Note that before the pipe was cast, and the look I know that part of the code
108 | # belongs to structure above
109 | if host -t ptr "$ipaddress" \
110 | | cut -d ' ' -f5 \
111 | | grep "^$fqdn\.$" > /dev/null
112 | then
113 | status=0
114 | fi
115 |
116 | return $status
117 | }
118 | ```
119 |
120 | ## How about manpages?
121 |
122 | * Each function have its own manpage.
123 | * The official language is English.
124 |
125 | ###### Reference
126 |
127 | https://github.com/funcoeszz/funcoeszz/wiki/Coding-Style
--------------------------------------------------------------------------------
/doc/source/conf.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | #
4 | # bashacks documentation build configuration file, created by
5 | # sphinx-quickstart on Tue Dec 29 17:21:13 2015.
6 | #
7 | # This file is execfile()d with the current directory set to its
8 | # containing dir.
9 | #
10 | # Note that not all possible configuration values are present in this
11 | # autogenerated file.
12 | #
13 | # All configuration values have a default; values that are commented out
14 | # serve to show the default.
15 |
16 | import sys
17 | import os
18 | import shlex
19 |
20 | # If extensions (or modules to document with autodoc) are in another directory,
21 | # add these directories to sys.path here. If the directory is relative to the
22 | # documentation root, use os.path.abspath to make it absolute, like shown here.
23 | #sys.path.insert(0, os.path.abspath('.'))
24 |
25 | # -- General configuration ------------------------------------------------
26 |
27 | # If your documentation needs a minimal Sphinx version, state it here.
28 | #needs_sphinx = '1.0'
29 |
30 | # Add any Sphinx extension module names here, as strings. They can be
31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32 | # ones.
33 | extensions = []
34 |
35 | # Add any paths that contain templates here, relative to this directory.
36 | templates_path = ['_templates']
37 |
38 | # The suffix(es) of source filenames.
39 | # You can specify multiple suffix as a list of string:
40 | # source_suffix = ['.rst', '.md']
41 | source_suffix = '.rst'
42 |
43 | # The encoding of source files.
44 | #source_encoding = 'utf-8-sig'
45 |
46 | # The master toctree document.
47 | master_doc = 'index'
48 |
49 | # General information about the project.
50 | project = 'bashacks'
51 | copyright = '2015, Fernando Merces, Wesley Leite'
52 | author = 'Fernando Merces, Wesley Leite'
53 |
54 | # The version info for the project you're documenting, acts as replacement for
55 | # |version| and |release|, also used in various other places throughout the
56 | # built documents.
57 | #
58 | # The short X.Y version.
59 | version = '2.0.0'
60 | # The full version, including alpha/beta/rc tags.
61 | release = '2.0.0'
62 |
63 | # The language for content autogenerated by Sphinx. Refer to documentation
64 | # for a list of supported languages.
65 | #
66 | # This is also used if you do content translation via gettext catalogs.
67 | # Usually you set "language" from the command line for these cases.
68 | language = None
69 |
70 | # There are two options for replacing |today|: either, you set today to some
71 | # non-false value, then it is used:
72 | #today = ''
73 | # Else, today_fmt is used as the format for a strftime call.
74 | #today_fmt = '%B %d, %Y'
75 |
76 | # List of patterns, relative to source directory, that match files and
77 | # directories to ignore when looking for source files.
78 | exclude_patterns = []
79 |
80 | # The reST default role (used for this markup: `text`) to use for all
81 | # documents.
82 | #default_role = None
83 |
84 | # If true, '()' will be appended to :func: etc. cross-reference text.
85 | #add_function_parentheses = True
86 |
87 | # If true, the current module name will be prepended to all description
88 | # unit titles (such as .. function::).
89 | #add_module_names = True
90 |
91 | # If true, sectionauthor and moduleauthor directives will be shown in the
92 | # output. They are ignored by default.
93 | #show_authors = False
94 |
95 | # The name of the Pygments (syntax highlighting) style to use.
96 | pygments_style = 'sphinx'
97 |
98 | # A list of ignored prefixes for module index sorting.
99 | #modindex_common_prefix = []
100 |
101 | # If true, keep warnings as "system message" paragraphs in the built documents.
102 | #keep_warnings = False
103 |
104 | # If true, `todo` and `todoList` produce output, else they produce nothing.
105 | todo_include_todos = False
106 |
107 |
108 | # -- Options for HTML output ----------------------------------------------
109 |
110 | # The theme to use for HTML and HTML Help pages. See the documentation for
111 | # a list of builtin themes.
112 | #html_theme = 'alabaster'
113 | html_theme = 'sphinx_rtd_theme'
114 |
115 | # Theme options are theme-specific and customize the look and feel of a theme
116 | # further. For a list of options available for each theme, see the
117 | # documentation.
118 | #html_theme_options = {}
119 |
120 | # Add any paths that contain custom themes here, relative to this directory.
121 | #html_theme_path = []
122 |
123 | # The name for this set of Sphinx documents. If None, it defaults to
124 | # " v documentation".
125 | #html_title = None
126 |
127 | # A shorter title for the navigation bar. Default is the same as html_title.
128 | #html_short_title = None
129 |
130 | # The name of an image file (relative to this directory) to place at the top
131 | # of the sidebar.
132 | #html_logo = None
133 |
134 | # The name of an image file (within the static path) to use as favicon of the
135 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136 | # pixels large.
137 | #html_favicon = None
138 |
139 | # Add any paths that contain custom static files (such as style sheets) here,
140 | # relative to this directory. They are copied after the builtin static files,
141 | # so a file named "default.css" will overwrite the builtin "default.css".
142 | html_static_path = ['_static']
143 |
144 | # Add any extra paths that contain custom files (such as robots.txt or
145 | # .htaccess) here, relative to this directory. These files are copied
146 | # directly to the root of the documentation.
147 | #html_extra_path = []
148 |
149 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
150 | # using the given strftime format.
151 | #html_last_updated_fmt = '%b %d, %Y'
152 |
153 | # If true, SmartyPants will be used to convert quotes and dashes to
154 | # typographically correct entities.
155 | #html_use_smartypants = True
156 |
157 | # Custom sidebar templates, maps document names to template names.
158 | #html_sidebars = {}
159 |
160 | # Additional templates that should be rendered to pages, maps page names to
161 | # template names.
162 | #html_additional_pages = {}
163 |
164 | # If false, no module index is generated.
165 | #html_domain_indices = True
166 |
167 | # If false, no index is generated.
168 | #html_use_index = True
169 |
170 | # If true, the index is split into individual pages for each letter.
171 | #html_split_index = False
172 |
173 | # If true, links to the reST sources are added to the pages.
174 | #html_show_sourcelink = True
175 |
176 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
177 | #html_show_sphinx = True
178 |
179 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
180 | #html_show_copyright = True
181 |
182 | # If true, an OpenSearch description file will be output, and all pages will
183 | # contain a tag referring to it. The value of this option must be the
184 | # base URL from which the finished HTML is served.
185 | #html_use_opensearch = ''
186 |
187 | # This is the file name suffix for HTML files (e.g. ".xhtml").
188 | #html_file_suffix = None
189 |
190 | # Language to be used for generating the HTML full-text search index.
191 | # Sphinx supports the following languages:
192 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
193 | # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
194 | #html_search_language = 'en'
195 |
196 | # A dictionary with options for the search language support, empty by default.
197 | # Now only 'ja' uses this config value
198 | #html_search_options = {'type': 'default'}
199 |
200 | # The name of a javascript file (relative to the configuration directory) that
201 | # implements a search results scorer. If empty, the default will be used.
202 | #html_search_scorer = 'scorer.js'
203 |
204 | # Output file base name for HTML help builder.
205 | htmlhelp_basename = 'bashacksdoc'
206 |
207 | # -- Options for LaTeX output ---------------------------------------------
208 |
209 | latex_elements = {
210 | # The paper size ('letterpaper' or 'a4paper').
211 | #'papersize': 'letterpaper',
212 |
213 | # The font size ('10pt', '11pt' or '12pt').
214 | #'pointsize': '10pt',
215 |
216 | # Additional stuff for the LaTeX preamble.
217 | #'preamble': '',
218 |
219 | # Latex figure (float) alignment
220 | #'figure_align': 'htbp',
221 | }
222 |
223 | # Grouping the document tree into LaTeX files. List of tuples
224 | # (source start file, target name, title,
225 | # author, documentclass [howto, manual, or own class]).
226 | latex_documents = [
227 | (master_doc, 'bashacks.tex', 'bashacks Documentation',
228 | 'Fernando Merces, Wesley Leite', 'manual'),
229 | ]
230 |
231 | # The name of an image file (relative to this directory) to place at the top of
232 | # the title page.
233 | #latex_logo = None
234 |
235 | # For "manual" documents, if this is true, then toplevel headings are parts,
236 | # not chapters.
237 | #latex_use_parts = False
238 |
239 | # If true, show page references after internal links.
240 | #latex_show_pagerefs = False
241 |
242 | # If true, show URL addresses after external links.
243 | #latex_show_urls = False
244 |
245 | # Documents to append as an appendix to all manuals.
246 | #latex_appendices = []
247 |
248 | # If false, no module index is generated.
249 | #latex_domain_indices = True
250 |
251 |
252 | # -- Options for manual page output ---------------------------------------
253 |
254 | # One entry per manual page. List of tuples
255 | # (source start file, name, description, authors, manual section).
256 | man_pages = [
257 | (master_doc, 'bashacks', 'bashacks Documentation',
258 | [author], 1)
259 | ]
260 |
261 | # If true, show URL addresses after external links.
262 | #man_show_urls = False
263 |
264 |
265 | # -- Options for Texinfo output -------------------------------------------
266 |
267 | # Grouping the document tree into Texinfo files. List of tuples
268 | # (source start file, target name, title, author,
269 | # dir menu entry, description, category)
270 | texinfo_documents = [
271 | (master_doc, 'bashacks', 'bashacks Documentation',
272 | author, 'bashacks', 'One line description of project.',
273 | 'Miscellaneous'),
274 | ]
275 |
276 | # Documents to append as an appendix to all manuals.
277 | #texinfo_appendices = []
278 |
279 | # If false, no module index is generated.
280 | #texinfo_domain_indices = True
281 |
282 | # How to display URL addresses: 'footnote', 'no', or 'inline'.
283 | #texinfo_show_urls = 'footnote'
284 |
285 | # If true, do not generate a @detailmenu in the "Top" node's menu.
286 | #texinfo_no_detailmenu = False
287 |
--------------------------------------------------------------------------------
/doc/source/crypto.rst:
--------------------------------------------------------------------------------
1 | Crypto
2 | =======
3 |
4 | In this page, you will found information from all functions of cryptograpy on the bashacks
5 |
6 |
7 | bh_hashcrack
8 | ------------
9 |
10 | This is our old function ``bh_unmd5`` with many improvements, now can with several hashes, just update the name.
11 |
12 | In this new version we cache the hash that have already been found, improving delivery speed.
13 |
14 | .. note:: Usage
15 |
16 | ``bh_hascrack`` [hash string]
17 |
18 |
19 | Supported hash string for decryption:
20 |
21 | ``md5``, ``sha1``, ``sha256``, ``sha384``, ``sha512``
22 |
23 |
24 | .. code-block:: bash
25 |
26 | #md5
27 | $ bh_hashcrack e10adc3949ba59abbe56e057f20f883e
28 | 123456
29 |
30 | #sha1
31 | $ bh_hashcrack 38464bf083d958b53580c63c01e56707fd043588
32 | rock
33 |
34 | #sha256
35 | $ bh_hashcrack 9ca0f72f324a7bd2c2efc64b40d1e769a473451c2b9e5dfbd54a9db53c986ba5
36 | mamonas
37 |
38 | #sha384
39 | $ bh_hashcrack 504f008c8fcf8b2ed5dfcde752fc5464ab8ba064215d9c514785180d2ad7cee1ab792ad44798c
40 | 1234
41 |
42 | #sha512
43 | $ bh_hashcrack 5b01e57fd8ab53cc7c0d2a97585ba5a9d70f0dc966472b32736c52a4823f3fb43532dfc1e83fd2d92f1a7dbec8c401f4d7355b67accec
44 | hack
45 |
46 | This function has given a lot of work, many upgrades, have a good time that we have to find a good source hashed base.
47 |
48 |
49 | bh_rot
50 | ------
51 |
52 | Encrypts/Decrypts string with the Cesar Cipher using n shifts to the right.
53 |
54 | .. note:: Usage
55 |
56 | ``bh_rot`` [int] [string]
57 |
58 | int : Aumount of jumps you want to give to the right
59 |
60 | string : string to code or decode
61 |
62 |
63 | .. code-block:: bash
64 |
65 | $ bh_rot 3 terra
66 | whuud
67 | $ bh_rot 13 terra
68 | green
69 |
70 |
71 | .. sidebar:: Facilities
72 |
73 | We created some facilities, aliases for multiple entries of ``rot`` function, see below.
74 |
75 | .. code-block:: bash
76 |
77 | $ bh_rot13 terra
78 | green
79 | $ bh_rot18 terra
80 | lwjjs
81 | $ bh_rot47 adjust
82 |
83 | $ bh_rot5 terra
84 | yjwwf
85 |
86 |
87 | bh_rotall is an implementation that accesses rot generating 1..25 results to rot.
88 |
89 | .. code-block:: bash
90 |
91 | $ bh_rotall urfn
92 | ROT1 vsgo
93 | ROT2 wthp
94 | ROT3 xuiq
95 | ROT4 yvjr
96 | ROT5 zwks
97 | ROT6 axlt
98 | ROT7 bymu
99 | ROT8 cznv
100 | ROT9 daow
101 | ROT10 ebpx
102 | ROT11 fcqy
103 | ROT12 gdrz
104 | ROT13 hesa
105 | ROT14 iftb
106 | ROT15 jguc
107 | ROT16 khvd
108 | ROT17 liwce
109 | ROT18 mjxf
110 | ROT19 nkyg
111 | ROT20 olzh
112 | ROT21 pmai
113 | ROT22 qnbj
114 | ROT23 rock
115 | ROT24 spdl
116 | ROT25 tqem
117 |
118 |
119 | bh_strxor
120 | ---------
121 |
122 | Calculates exclusive OR of each character in a string with a key.
123 |
124 | .. note:: Usage
125 |
126 | ``bh_strxor`` [key] [string]
127 |
128 | key : int or hex
129 |
130 | string: string to code or decode
131 |
132 |
133 | .. code-block:: bash
134 |
135 | $ bh_strxor 15 'hack'
136 | gnld
137 |
138 | $ bh_strxor 15 'gnld'
139 | hack
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/doc/source/filesystem.rst:
--------------------------------------------------------------------------------
1 | Filesystem
2 | ===========
3 |
4 | This section in general has funcions for file handling.
5 |
6 | bh_bkp
7 | ------
8 |
9 | Do quick backup of file using the current system date posfixed to the filename
10 |
11 | .. note::
12 | Usage
13 |
14 | ``bh_bkp`` [filename]
15 |
16 |
17 | .. code-block:: bash
18 |
19 | $ bh_bkp bashacks.sh
20 | $ ls -1
21 | bashacks.sh
22 | bashacks.sh.20160122
23 |
24 |
25 | bh_findmime
26 | ------------
27 |
28 | Find file by mime type
29 |
30 | .. note::
31 |
32 | Usage
33 |
34 | ``bh_findmime`` -[type] [directory]
35 |
36 | type : -exe, -msi, -txt or -zip
37 |
38 | directory : path
39 |
40 |
41 | .. code-block:: bash
42 |
43 | $ bh_findmime -exe ~/Downloads
44 | /home/bashacks/Downloads//binario.exe
45 |
46 | $ bh_findmime -txt ~/Documents
47 | /home/bashacks/Documents//01-text.txt
48 | /home/bashacks/Documents//ha.log
49 |
50 | $ bh_findmime -zip ~/
51 | /home/bashacks//crm.zip
52 |
53 | $ bh_findmime -msi ~/
54 | /home/bashacks//install.msi
55 |
56 |
57 |
58 | bh_hashes
59 | ---------
60 |
61 | Generate message digest md5, sha1 and sha256 from file or list of file sent by parameters.
62 |
63 | .. note::
64 |
65 | Usage
66 |
67 | ``bh_hashes`` [filename or list of files]
68 |
69 |
70 | .. code-block:: bash
71 |
72 | $ $ bh_hashes bashacks.sh
73 | 5dab37cac730088fd959f8292636fc9b bashacks.sh
74 | 38be74a4e710a3eeb24b4fa2015cea990d4eda67 bashacks.sh
75 | 587b713bb31e3bf32de0b734805c3dd247f49a14cd9e9a5f35008e4f620d3f82 bashacks.sh
76 |
77 |
78 | bh_md5rename
79 | ------------
80 |
81 | Convert filename to equivalent digest md5.
82 |
83 | .. note::
84 |
85 | Usage
86 |
87 | ``bh_md5rename`` [filename or list of files]
88 |
89 |
90 | .. code-block:: bash
91 |
92 | $ touch ment.bin
93 | $ bh_md5rename ment.bin
94 | $ ls
95 | d41d8cd98f00b204e9800998ecf8427e
96 |
97 |
98 | .. sidebar:: TIP
99 |
100 | It's easy compress a file and send it by mail later or protection you from yourself.
101 |
102 |
103 | bh_secretfile
104 | ---------
105 |
106 | A nice feature to any skill, use it to compress one or more files, automatically generating a password and upload to the file.io, in the end of process you'll get a URL and password to decompress file.
107 |
108 | .. note::
109 |
110 | Usage
111 |
112 | ``bh_secretfile`` [filename]
113 |
114 |
115 | .. code-block:: bash
116 |
117 | $ cat > ment.bin
118 | Hi, I'm send this file.
119 | $ bh_secretfile ment.bin
120 | adding: ment.bin (stored 0%)
121 | https://file.io/Raan5CUW8ZTW
122 | NRvC_ZniiEtlwgcrBbI_
123 |
124 |
125 | bh_sharefile
126 | ---------
127 |
128 | Just as the bh_secretfile function uploads a file and returns the unique url to access it, this process will not have a password attached, anyone with the URL will be able to download it.
129 |
130 | .. note::
131 |
132 | Usage
133 |
134 | ``bh_sharefile`` [filename]
135 |
136 |
137 | .. code-block:: bash
138 |
139 | $ bh_sharefile texto.txt
140 | https://file.io/EGQvRxqyagIY
141 |
142 |
143 | bh_zipmal
144 | ---------
145 |
146 | Copress file in zip format with password protection. the password is ``virus``
147 |
148 | .. note::
149 |
150 | Usage
151 |
152 | ``bh_zipmal`` [filename]
153 |
154 |
155 | .. code-block:: bash
156 |
157 | $ bh_zipmal malware.cpl
158 | adding: malware.cpl (deflated 69%)
159 | -rw-r--r-- 1 bashacks users 30k Jan 21 23:57 malware.zip
160 |
161 |
162 |
163 |
--------------------------------------------------------------------------------
/doc/source/index.rst:
--------------------------------------------------------------------------------
1 | .. bashacks documentation master file, created by
2 | sphinx-quickstart on Tue Dec 29 17:21:13 2015.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | Welcome to bashacks's documentation!
7 | ====================================
8 |
9 | Bashacks is an open source (GPL) set of bash functions probably useful for programmers, security analysts and general users that need to do some low level type of operation.
10 |
11 | In fact, there nothing really new bashacks since all functions are write using exiting software in GNU/Linux distribuitions.
12 |
13 | But you still can have advantage in use short commands to run tasks that commomnly will require a ot of lines to be done.
14 |
15 |
16 | Contents:
17 |
18 | .. toctree::
19 | :maxdepth: 2
20 |
21 | .. include:: install.rst
22 |
23 | .. include:: crypto.rst
24 |
25 | .. include:: filesystem.rst
26 |
27 | .. include:: math.rst
28 |
29 | .. include:: net.rst
30 |
31 | .. include:: programming.rst
32 |
33 | .. include:: reversing.rst
34 |
35 | .. include:: string.rst
36 |
37 |
38 |
--------------------------------------------------------------------------------
/doc/source/install.rst:
--------------------------------------------------------------------------------
1 | Install
2 | =======
3 |
4 | In this section you can find instructions bashacks's installation process, if you have any tips to improve, send your opinion. ;)
5 |
6 | Requirements
7 | ------------
8 |
9 | * bash >= 4
10 | * bc
11 | * binutils
12 | * coreutils
13 | * curl
14 | * file
15 | * grep
16 | * hexdump
17 | * html2text
18 | * perl
19 | * sed
20 | * wget
21 | * xxd
22 | * zip
23 | * make
24 |
25 | We consider that your system has the minimum instalation of packages, if you are using some of the below no problems.
26 |
27 | .. code-block:: text
28 |
29 | GNU/Linux
30 | FreeBSD (new)
31 | OSX (new)
32 |
33 |
34 | Download
35 | --------
36 |
37 | .. sidebar:: GIT
38 |
39 | We recommend the version available on ``MASTER REPOSITORY ON THE GITHUB``, however, if you want to use the development version skip the session that describe the steps of the GIT
40 |
41 | Download the final version, download on the ``GITHUB``. `Download Bashacks`_
42 |
43 |
44 | GIT
45 | ---
46 |
47 | Since the end of version ``1.5.0`` we are working with separate branches for various activities, can have errors and problems in ``devel`` repository, but try to keep always clean ``master`` branch to your advantage.
48 |
49 |
50 | .. code-block:: bash
51 |
52 | $ git clone https://github.com/merces/bashacks.git
53 | $ cd bashacks
54 | # this's a optional mode, maybe there's some error in the devel branch.
55 | $ git checkout devel
56 |
57 |
58 |
59 | Compile
60 | -------
61 |
62 | .. code-block:: text
63 |
64 | Options
65 |
66 | all : Just creates the file bashacks.sh
67 | install : Creates the file bashacks.sh, add entry in /etc/bash.bashrc and install man page
68 | clean : Just remove the file bashacks.sh
69 | uninstall : remove reference the source of /etc/bash.bashrc and man page
70 |
71 |
72 | .. code-block:: bash
73 |
74 | $ make all
75 | $ source bashacks.sh
76 |
77 |
78 | Done that all functions can be used use ``bh`` ``TAB`` ``TAB`` and has a ``Sight beyond sight``
79 |
80 |
81 |
82 | .. _`Download bashacks`: https://github.com/merces/bashacks/archive/refs/heads/master.zip
83 |
84 |
85 |
--------------------------------------------------------------------------------
/doc/source/math.rst:
--------------------------------------------------------------------------------
1 | Math
2 | ====
3 |
4 | In this section, we will have many funcions of mathematics operations that help us in everyday life.
5 |
6 | They are not complex to assemble in bash, however, nothing better than a small function to assist, nothing better that send data and get or return result, always read the code.
7 |
8 |
9 | bh_bin2dec
10 | ----------
11 |
12 | This function expects a binary and return its equivalent in decimal.
13 |
14 | .. note::
15 |
16 | Usage
17 |
18 | ``bh_bin2dec`` [binary]
19 |
20 | binary : string in binary format.
21 |
22 |
23 | .. code-block:: bash
24 |
25 | $ bh_bin2dec 11111111
26 | 255
27 |
28 | $ bh_bin2dec 10
29 | 2
30 |
31 | $ bh_bin2dec 1110
32 | 14
33 |
34 |
35 | bh_charcalc
36 | -----------
37 |
38 | Think of a way to make operations with 'char', how to sum two positions for a 'char/string' and return letter c or sum of the other and multiply it by 10 and returns 10
39 |
40 | .. note::
41 |
42 | Usage
43 |
44 | ``bh_charcalc`` [char/string] [operator] [number]
45 |
46 | char/string : string or char to operation
47 | operator : \* + -
48 | number : num of operation
49 |
50 |
51 | .. code-block:: bash
52 |
53 | $ bh_charcalc A + 2
54 | C
55 |
56 | $ bh_charcalc A \* 255
57 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA.......
58 |
59 |
60 | bh_dec2bin
61 | ----------
62 |
63 | Opossed to ``bh_bin2dec`` this function expects a decimal for converting it into binary.
64 |
65 |
66 | .. note::
67 |
68 | Usage
69 |
70 | ``bh_dec2bin`` [decimal]
71 |
72 | decimal : number in decimal format.
73 |
74 |
75 | .. code-block:: bash
76 |
77 | $ bh_dec2bin 255
78 | 11111111
79 |
80 | $ bh_dec2bin 2
81 | 10
82 |
83 | $ bh_dec2bin 14
84 | 1110
85 |
86 | #Example
87 |
88 | $ for dec in {1..6};
89 | do
90 | echo "$dec = $(bh_dec2bin $dec)";
91 | done
92 |
93 | 1 = 1
94 | 2 = 10
95 | 3 = 11
96 | 4 = 100
97 | 5 = 101
98 | 6 = 110
99 |
100 |
101 | bh_dec2hex
102 | ----------
103 |
104 | The function expects a input a decimal number it performs the conversion to hex.
105 |
106 | .. note::
107 |
108 | Usage
109 |
110 | ``bh_dec2hex`` [decimal]
111 |
112 | decimal: number in decimal format
113 |
114 |
115 | .. code-block:: bash
116 |
117 | $ bh_dec2hex 10
118 | a
119 |
120 | $ bh_dec2hex 255
121 | ff
122 |
123 |
124 | bh_hex2bin
125 | ----------
126 |
127 | Capture all submitted arguments and convert to binary
128 |
129 | .. note::
130 |
131 | Usage
132 |
133 | ``bh_hex2bin`` [list or one hex digit]
134 |
135 |
136 | .. code-block:: bash
137 |
138 | $ bh_hex2bin abcdef 1 2 3
139 | 101010111100110111101111 1 10 11
140 |
141 | $ bh_hex2bin 10
142 | 10000
143 |
144 |
145 | bh_hex2dec
146 | ----------
147 |
148 | This's a conversion function from hex digit to decimal digit
149 |
150 | .. note::
151 |
152 | Usage
153 |
154 | ``bh_hex2dec`` [one or more hex digit]
155 |
156 |
157 | .. code-block:: bash
158 |
159 | $ bh_hex2dec A
160 | 10
161 |
162 | $ bh_hex2dec FF
163 | 255
164 |
165 |
166 | bh_hexcalc
167 | ----------
168 |
169 | In the same way as ``bh_charcalc``, however, work here with hexdigit.
170 |
171 | .. note::
172 |
173 | Usage
174 |
175 | ``bh_hex2cal`` [hex digit] [operator] [hex digit]
176 |
177 |
178 | .. code-block:: bash
179 |
180 | $ bh_hex2dec A \* 2
181 | 0xa0
182 |
183 | $ bh_hex2bin FF + 1
184 | 0x100
185 |
186 |
--------------------------------------------------------------------------------
/doc/source/net.rst:
--------------------------------------------------------------------------------
1 | Network
2 | ========
3 |
4 |
5 | bh_bin2ip
6 | ---------
7 | Convert a binary string into network ipaddress.
8 |
9 | .. note::
10 |
11 | Usage
12 |
13 | ``bh_bin2ip`` binary string
14 |
15 |
16 | .. code-block:: bash
17 |
18 | $ bh_bin2ip 00001010.00001010.00000000.00000001
19 | 10.10.0.1
20 |
21 |
22 | bh_hostcalc
23 | -----------
24 | Enter a network CIDR mask and know the amount of hosts
25 |
26 | .. note::
27 |
28 | Usage
29 |
30 | ``bh_hostcalc`` [ mask cidr ]
31 |
32 | .. code-block:: bash
33 |
34 | $ bh_hostcalc 24
35 | 256
36 |
37 | $ bh_hostcalc 25
38 | 126
39 |
40 |
41 |
42 | bh_ip2bin
43 | ---------
44 | Convert network ipaddress into binary string.
45 |
46 | .. note::
47 |
48 | Usage
49 |
50 | ``bh_ip2bin`` [ ipaddress ]
51 |
52 | .. code-block:: bash
53 |
54 | $ bh_ip2bin 192.168.0.100
55 | 11000000.10101000.00000000.01100100
56 |
57 |
58 |
59 | bh_myip
60 | -------
61 |
62 | This returns the external ipaddress of your network connection.
63 |
64 | .. note::
65 |
66 | Usage
67 |
68 | ``bh_myip``
69 |
70 |
71 | .. code-block:: bash
72 |
73 | $ bh_myip
74 | 200.251.1.1
75 |
76 |
77 |
78 | bh_wgetr
79 | --------
80 |
81 | Recursive and continue getting a partially-downloaded "if exist" file started by a previous instance of wget with randomize time.
82 |
83 | .. note::
84 |
85 | Usage
86 |
87 | ``bh_wgetr`` [ url ]
88 |
89 |
90 | .. code-block:: bash
91 |
92 | $ bh_wgetr http://www.mentebinaria.com.br/artigos/0x1e/0x1e-maqengrevwin.html
93 | www.mentebinaria.com.br/art 100%[==========================================>] 8.73K --.-KB/s in 0s
94 | www.mentebinaria.com.br/rob 100%[==========================================>] 361 --.-KB/s in 0s
95 | www.mentebinaria.com.br/art 100%[==========================================>] 66.18K 132KB/s in 0.5s
96 | $ ls -1
97 | www.mentebinaria.com.br
98 | $ ls -1 www.mentebinaria.com.br/artigos/0x1e/
99 | 0x1e-maqengrevwin.html
100 | desktop.png
101 |
102 |
103 | bh_ipinfo
104 | ---------
105 |
106 | Query ipinfo.io returns basic info about address.
107 |
108 | .. note::
109 |
110 | Usage
111 |
112 | ``bh_ipinfo`` [ ipaddress ]
113 |
114 | .. code-block:: bash
115 |
116 | $ $ bh_ipinfo 8.8.8.8
117 | {
118 | "ip": "8.8.8.8",
119 | "hostname": "dns.google",
120 | "anycast": true,
121 | "city": "Mountain View",
122 | "region": "California",
123 | "country": "US",
124 | "loc": "37.4056,-122.0775",
125 | "org": "AS15169 Google LLC",
126 | "postal": "94043",
127 | "timezone": "America/Los_Angeles",
128 | "readme": "https://ipinfo.io/missingauth"
129 | }
130 |
131 |
132 | bh_unshort
133 | ---------
134 |
135 | With this function you have the possibility to unshort a URL see below a example.
136 |
137 | .. note::
138 |
139 | Usage
140 |
141 | ``bh_unshort`` [ URL string ]
142 |
143 | .. code-block:: bash
144 |
145 | $ bh_unshort http://goo.gl/l6MS
146 | http://googleblog.blogspot.com/2009/12/making-urls-shorter-for-google-toolbar.html
147 |
148 |
149 | bh_ipisblacklisted
150 | ---------
151 |
152 | Search for occurrence of the ip address in some blacklist returning [T] if positive and [F] if it is opposite..
153 |
154 | .. note::
155 |
156 | Usage
157 |
158 | ``bh_ipblacklist`` [ ipaddress ]
159 |
160 | .. code-block:: bash
161 |
162 | $ bh_ipblacklist 77.xxx.xx.xx
163 | == 77.xxx.xx.xx ==
164 | [F] TALOS
165 | [F] Malc0de
166 | [F] Projecthoneypot.org
167 | [F] blocklist.de
168 | [T] Alienvault
169 | [F] SANS-TOPSOURCE
170 |
171 | #if ipaddress is not informed will be considered the outside
172 |
173 | $ bh_ipblacklist
174 | == 189.x.xxx.x ==
175 | [F] TALOS
176 | [F] Malc0de
177 | [F] blocklist.de
178 | [F] Alienvault
179 | [T] SANS-TOPSOURCE
180 |
181 |
--------------------------------------------------------------------------------
/doc/source/programming.rst:
--------------------------------------------------------------------------------
1 | Programming
2 | ===========
3 |
4 | Session for the creation of facilitators for development in cli
5 |
6 |
7 | bh_skel_c
8 | ---------
9 | Generates on the standard output ``C`` skeleton.
10 |
11 | .. note::
12 |
13 | Usage
14 |
15 | ``bh_skel_c``
16 |
17 | .. code-block:: bash
18 |
19 | $ bh_skel_c
20 | #include
21 |
22 | int main(int argc, char ***argv[]**) {
23 |
24 | return 0;
25 | }
26 |
27 |
28 | bh_skel_go
29 | ---------
30 | Generates on the standard output ``go`` skeleton.
31 |
32 | .. note::
33 |
34 | Usage
35 |
36 | ``bh_skel_go``
37 |
38 | .. code-block:: bash
39 |
40 | $ bh_skel_go
41 | package main
42 |
43 | import (
44 | "fmt"
45 | )
46 |
47 | func main() {
48 |
49 | fmt.Println("test")
50 | }
51 |
52 |
53 | bh_skel_latex
54 | ---------
55 | Generates on the standard output ``latex`` skeleton.
56 |
57 | .. note::
58 |
59 | Usage
60 |
61 | ``bh_skel_latex``
62 |
63 | .. code-block:: bash
64 |
65 | $ bh_skel_latex
66 | \documentclass{article}
67 |
68 | \usepackage[english]{babel}
69 | \usepackage[utf8]{inputenc}
70 | \usepackage[margin=1in]{geometry}
71 |
72 | \author{}
73 | \title{}
74 |
75 | \begin{document}
76 | \maketitle
77 |
78 | \end{document}
79 |
80 |
81 | bh_skel_python
82 | --------------
83 |
84 | Generates on the standard output ``python`` skeleton.
85 |
86 | .. note::
87 |
88 | Usage
89 |
90 | ``bh_skel_python``
91 |
92 | .. code-block:: bash
93 |
94 | $ bh_skel_python
95 | #!/usr/bin/env python
96 | # *-* coding: utf-8 *-*
97 |
98 | if __name__ == '__main__':
99 |
100 |
101 | bh_skel_yara
102 | --------------
103 |
104 | Generates on the standard output ``yara`` skeleton.
105 |
106 | .. note::
107 |
108 | Usage
109 |
110 | ``bh_skel_yara``
111 |
112 | .. code-block:: bash
113 |
114 | $ bh_skel_yara
115 | rule test {
116 | meta:
117 | author = "mb"
118 | description = ""
119 | date = "2022-03-03"
120 | ref = ""
121 | hash = ""
122 |
123 | strings:
124 | $a = "test" ascii wide
125 |
126 | condition:
127 | all of them
128 | }
129 |
130 |
131 |
--------------------------------------------------------------------------------
/doc/source/reversing.rst:
--------------------------------------------------------------------------------
1 | Reversing
2 | =========
3 |
4 | bh_asmgrep
5 | ----------
6 |
7 | With the binary attempts to find instruction asm and print 4 lines around.
8 |
9 |
10 | .. note::
11 |
12 | Usage
13 |
14 | ``bh_asmgrep``` [ asm instruction ] [ binary path ]
15 |
16 | .. code-block:: bash
17 |
18 | $ bh_asmgrep mov /bin/ls
19 | ....
20 | ....
21 | ....
22 | --
23 | 409f2e:66 90 : xchg %ax,%ax
24 | 409f30:80 7c 13 ff 2f : cmpb $0x2f,-0x1(%rbx,%rdx,1)
25 | 409f35:48 8d 42 ff : lea -0x1(%rdx),%rax
26 | 409f39:75 08 : jne 409f43 <__sprintf_chk@plt+0x7783>
27 | 409f3b:48 89 c2 : mov %rax,%rdx
28 | 409f3e:48 39 d5 : cmp %rdx,%rbp
29 | 409f41:75 ed : jne 409f30 <__sprintf_chk@plt+0x7770>
30 | 409f43:48 83 c4 08 : add $0x8,%rsp
31 | --
32 | .....
33 | .....
34 | .....
35 |
36 |
37 | bh_asminfo
38 | ----------
39 |
40 | Display information of instructions asm internet is required for help us.
41 |
42 | .. note::
43 |
44 | Usage
45 |
46 | ``bh_asminfo`` [ asm instruction ]
47 |
48 | .. code-block:: bash
49 |
50 | $ bh_asminfo mov
51 | mov
52 |
53 | |Code |Mnemonic |Description |
54 | |88 / r |MOV r/m8, r8 |Move r8 to r/m8 |
55 | |89 / r |MOV r/m16, r16 |Move r16 to r/m16 |
56 | |89 / r |MOV r/m32, r32 |Move r32 to r/m32 |
57 | |8A / r |MOV r8, r/m8 |Move r/m8 to r8 |
58 | |8B / r |MOV r16, r/m16 |Move r/m16 to r16 |
59 | .......
60 | .......
61 | .......
62 |
63 |
64 | bh_replacestring
65 | ----------
66 |
67 | Find and replace string occurrence in the file, attention: the original file will
68 | be replacede by the new generated file.
69 |
70 | .. note::
71 |
72 | Usage
73 |
74 | ``bh_replacestring`` [ file ] [ string to search ] [ string to replace ]
75 |
76 | .. code-block:: bash
77 |
78 | $ hexdump -C MB_DEV
79 | .......
80 | 00000690 2e 00 54 00 58 00 54 00 2e 00 00 00 73 00 77 00 |..T.X.T.....s.w.|
81 | 000006a0 e5 45 53 54 45 54 7e 31 53 57 58 20 00 65 a1 9b |.ESTET~1SWX .e..|
82 | 000006b0 8b 54 8b 54 00 00 a1 9b 8b 54 00 00 00 00 00 00 |.T.T.....T......|
83 | 000006c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
84 | *
85 | 00005e00 4d 65 6e 74 65 42 69 6e 61 72 69 61 0a 00 00 00 |MenteBinaria....|
86 | 00005e10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
87 | *
88 | $ bh_replacestring MB_DEV MenteBinaria BinariaMente
89 | $ hexdump -C MB_DEV
90 | .......
91 | 00000690 2e 00 54 00 58 00 54 00 2e 00 00 00 73 00 77 00 |..T.X.T.....s.w.|
92 | 000006a0 e5 45 53 54 45 54 7e 31 53 57 58 20 00 65 a1 9b |.ESTET~1SWX .e..|
93 | 000006b0 8b 54 8b 54 00 00 a1 9b 8b 54 00 00 00 00 00 00 |.T.T.....T......|
94 | 000006c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
95 | *
96 | 00005e00 42 69 6e 61 72 69 61 4d 65 6e 74 65 0a 00 00 00 |BinariaMente....|
97 | 00005e10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
98 | *
99 |
100 |
101 | bh_zerostring
102 | ----------
103 |
104 | Replace with zero bytes in block or common file.
105 |
106 | .. note::
107 |
108 | Usage
109 |
110 | ``bh_zerostring`` [ file ] [ string to replace ]
111 |
112 | .. code-block:: bash
113 |
114 | # hexdump -C MB_DEV
115 | .....
116 | 00005860 41 4d 00 42 00 2d 00 66 00 69 00 0f 00 a1 6c 00 |AM.B.-.f.i....l.|
117 | 00005870 65 00 2e 00 74 00 78 00 74 00 00 00 00 00 ff ff |e...t.x.t.......|
118 | 00005880 4d 42 2d 46 49 4c 45 20 54 58 54 20 00 41 26 be |MB-FILE TXT .A&.|
119 | 00005890 69 54 69 54 00 00 26 be 69 54 05 00 1b 00 00 00 |iTiT..&.iT......|
120 | .....
121 | # bh_zerostring MB_DEV MB-FILE
122 | 7+0 records in
123 | 7+0 records out
124 | 7 bytes copied, 7.3484e-05 s, 95.3 kB/s
125 | # hexdump -C MB_DEV
126 | .....
127 | 00005860 41 4d 00 42 00 2d 00 66 00 69 00 0f 00 a1 6c 00 |AM.B.-.f.i....l.|
128 | 00005870 65 00 2e 00 74 00 78 00 74 00 00 00 00 00 ff ff |e...t.x.t.......|
129 | 00005880 00 00 00 00 00 00 00 20 54 58 54 20 00 41 26 be |....... TXT .A&.|
130 | 00005890 69 54 69 54 00 00 26 be 69 54 05 00 1b 00 00 00 |iTiT..&.iT......|
131 | .....
132 | # mount -o loop -t vfat MB_DEV /mnt/
133 | # ls -la /mnt/
134 | total 16
135 | drwxr-xr-x 2 root root 16384 Dec 31 1969 .
136 | drwxr-xr-x 1 root root 152 Feb 17 15:21 ..
137 |
138 |
--------------------------------------------------------------------------------
/doc/source/string.rst:
--------------------------------------------------------------------------------
1 | String
2 | =======
3 |
4 | In this section, you are see funcions for string manipulate.
5 |
6 |
7 | bh_asc2dec
8 | ----------
9 |
10 | This function performs the conversion of a char on it's decimal equivalent.
11 |
12 | .. note::
13 |
14 | ``bh_asc2dec`` [char]
15 |
16 | .. code-block:: bash
17 |
18 | $ bh_asc2dec a
19 | 97
20 | $ bh_asc2dec A
21 | 65
22 |
23 |
24 | bh_asciitable
25 | -------------
26 |
27 | Display in the terminal ascii table, if you are a programmer knows how this's important.
28 |
29 | .. note::
30 |
31 | ``bh_asciitable``
32 |
33 | .. code-block:: bash
34 |
35 | $ bh_asciitable
36 |
37 | Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex
38 | 0 00 NUL 16 10 DLE 32 20 48 30 0 64 40 @ 80 50 P 96 60 ` 112 70 p
39 | 1 01 SOH 17 11 DC1 33 21 ! 49 31 1 65 41 A 81 51 Q 97 61 a 113 71 q
40 | 2 02 STX 18 12 DC2 34 22 " 50 32 2 66 42 B 82 52 R 98 62 b 114 72 r
41 | 3 03 ETX 19 13 DC3 35 23 # 51 33 3 67 43 C 83 53 S 99 63 c 115 73 s
42 | 4 04 EOT 20 14 DC4 36 24 $ 52 34 4 68 44 D 84 54 T 100 64 d 116 74 t
43 | 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u
44 | 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v
45 | 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w
46 | 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x
47 | 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y
48 | 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z
49 | 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B {
50 | 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \ 108 6C l 124 7C |
51 | 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D }
52 | 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~
53 | 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL
54 |
55 |
56 |
57 | bh_dec2asc
58 | ----------
59 |
60 | Once having to enter a decimal returns it's equivalent in ascii.
61 |
62 | .. note::
63 |
64 | ``bh_dec2asc`` [decimal]
65 |
66 | decimal : dec equivalent of the ascii table to convert
67 |
68 | .. code-block:: bash
69 |
70 | $ bh_dec2asc 65
71 | A
72 | $ bh_dec2asc 41
73 | )
74 |
75 |
76 |
77 | bh_hex2str
78 | ----------
79 |
80 | Converts one or more bytes into a hex string to str.
81 |
82 | Accepts as input all output formats str2hex function.
83 |
84 | .. note::
85 |
86 | ``bh_hex2str`` [hex string]
87 |
88 |
89 | .. code-block:: bash
90 |
91 | $ bh_hex2str '72 6f 63 6b'
92 | rock
93 | $ bh_hex2str '0x726f636b'
94 | rock
95 | $ bh_hex2str '0x72 0x6f 0x63 0x6b'
96 | rock
97 | $ bh_hex2str '{0x72, 0x6f, 0x63, 0x6b}'
98 | rock
99 |
100 |
101 |
102 | bh_str2dec
103 | ----------
104 |
105 | Convert one or more bytes to their decimal equivalent.
106 |
107 |
108 | .. note::
109 |
110 | ``bh_str2dec`` [char or string]
111 |
112 |
113 | .. code-block:: bash
114 |
115 | $ bh_str2dec A
116 | 65
117 | $ bh_str2dec mbin
118 | 109 98 105 110
119 | $ bh_str2dec root
120 | 114 111 111 116
121 |
122 |
123 |
124 | bh_str2hexr
125 | -----------
126 |
127 | Converts string in hex byte equivalent to each char (hex string). reverse mode
128 |
129 | .. note::
130 |
131 | ``bh_str2hexr`` [-x] [-0x] [-c] [string]
132 |
133 | .. code-block:: bash
134 |
135 | $ bh_str2hexr 'Fernando'
136 | 6f 64 6e 61 6e 72 65 46
137 | $ bh_str2hexr -x 'Fernando'
138 | \x6f\x64\x6e\x61\x6e\x72\x65\x46
139 | $ bh_str2hexr -0x 'Fernado'
140 | 0x6f 0x64 0x6e 0x61 0x6e 0x72 0x65 0x46
141 |
142 |
143 | bh_str2hex
144 | ----------
145 |
146 | Converts string in hex byte equivalent to each char (hex string).
147 |
148 | .. note::
149 |
150 | ``bh_str2hex`` [-x] [-0x] [-c] [string]
151 |
152 | .. code-block:: bash
153 |
154 | $ bh_str2hex 'Fernando'
155 | 46 65 72 6e 61 6e 64 6f
156 | $ bh_str2hex -x 'Fernando'
157 | \x46\x65\x72\x6e\x61\x6e\x64\x6f
158 | $ bh_str2hex -0x 'Fernado'
159 | 0x46 0x65 0x72 0x6e 0x61 0x6e 0x64 0x6f
160 |
161 |
162 | bh_urldecode
163 | ------------
164 |
165 | Decode string with bh_urldecode from web standard to human format.
166 |
167 | .. note::
168 |
169 | ``bh_urldecode`` [encoded string]
170 |
171 | .. code-block:: bash
172 |
173 | $ bh_urldecode '%2fzzz%21%40%2e%23'
174 | /zzz!@.#
175 |
176 |
177 | bh_urlencode
178 | ------------
179 |
180 | Encoded string with bh_urlencode to web standard.
181 |
182 | .. note::
183 |
184 | ``bh_urlencode`` [string]
185 |
186 | .. code-block:: bash
187 |
188 | $ bh_urlencode '/zzz!@.#'
189 | %2fzzz%21%40%2e%23
190 |
191 |
192 | bh_utf8table
193 | ------------
194 |
195 | Show UTF8 table.
196 |
197 | .. note::
198 |
199 | ``bh_utf8table``
200 |
201 | .. code-block:: bash
202 |
203 | $ bh_utf8table
204 | Hex Hex Hex Hex Hex Hex Hex Hex
205 | c2 a0 c2 ac ¬ c2 b8 ¸ c3 84 Ä c3 90 Ð c3 9c Ü c3 a8 è c3 b4 ô
206 | c2 a1 ¡ c2 ad c2 b9 ¹ c3 85 Å c3 91 Ñ c3 9d Ý c3 a9 é c3 b5 õ
207 | c2 a2 ¢ c2 ae ® c2 ba º c3 86 Æ c3 92 Ò c3 9e Þ c3 aa ê c3 b6 ö
208 | c2 a3 £ c2 af ¯ c2 bb » c3 87 Ç c3 93 Ó c3 9f ß c3 ab ë c3 b7 ÷
209 | c2 a4 ¤ c2 b0 ° c2 bc ¼ c3 88 È c3 94 Ô c3 a0 à c3 ac ì c3 b8 ø
210 | c2 a5 ¥ c2 b1 ± c2 bd ½ c3 89 É c3 95 Õ c3 a1 á c3 ad í c3 b9 ù
211 | c2 a6 ¦ c2 b2 ² c2 be ¾ c3 8a Ê c3 96 Ö c3 a2 â c3 ae î c3 ba ú
212 | c2 a7 § c2 b3 ³ c2 bf ¿ c3 8b Ë c3 97 × c3 a3 ã c3 af ï c3 bb û
213 | c2 a8 ¨ c2 b4 ´ c3 80 À c3 8c Ì c3 98 Ø c3 a4 ä c3 b0 ð c3 bc ü
214 | c2 a9 © c2 b5 µ c3 81 Á c3 8d Í c3 99 Ù c3 a5 å c3 b1 ñ c3 bd ý
215 | c2 aa ª c2 b6 ¶ c3 82 Â c3 8e Î c3 9a Ú c3 a6 æ c3 b2 ò c3 be þ
216 | c2 ab « c2 b7 · c3 83 Ã c3 8f Ï c3 9b Û c3 a7 ç c3 b3 ó c3 bf ÿ
217 |
218 |
219 |
--------------------------------------------------------------------------------
/src/crypto/bh_rot.sh:
--------------------------------------------------------------------------------
1 | bh_rot() {
2 | (( $# < 2 )) && return 1
3 |
4 | local n
5 | local N
6 |
7 | # n gets the alphabet letter
8 | n=$(echo -e \\x$(bh_dec2hex $(( 97 + $1 )) ) )
9 |
10 | # N gets uppercase n
11 | N="${n^^}"
12 |
13 | # rot with tr command
14 | echo $2 | tr a-z $n-za-z | tr A-Z $N-ZA-Z
15 | }
16 |
--------------------------------------------------------------------------------
/src/crypto/bh_rotall.sh:
--------------------------------------------------------------------------------
1 | bh_rotall() {
2 | (( $# < 1 )) && return 1
3 |
4 | local i
5 |
6 | for i in {1..25}; do
7 | echo "ROT$i $(bh_rot $i "$1")"
8 | done
9 | }
10 |
--------------------------------------------------------------------------------
/src/crypto/bh_strxor.sh:
--------------------------------------------------------------------------------
1 | bh_strxor() {
2 | (( $# < 2 )) && return 1
3 |
4 | local str
5 | local xored
6 | local i
7 |
8 | # $2 is the string and $1 is the xor key
9 | str=$(bh_str2dec "$2")
10 |
11 | for i in $str; do
12 | xored=$(( $i ^ $1 ))
13 | echo -n "$(bh_dec2asc $xored)"
14 | done
15 | echo
16 | }
17 |
--------------------------------------------------------------------------------
/src/filesystem/bh_bkp.sh:
--------------------------------------------------------------------------------
1 | bh_bkp() {
2 | (( $# < 1 )) && return 1
3 | cp -vi "$1"{,.$(date +%Y%m%d)}
4 | }
5 |
--------------------------------------------------------------------------------
/src/filesystem/bh_findmime.sh:
--------------------------------------------------------------------------------
1 | bh_findmime() {
2 | (( $# < 2 )) && return 1
3 |
4 | local dir=.
5 | local filetype
6 | local opt
7 | local matches
8 |
9 | [[ -d "$2" ]] && dir="$2"
10 |
11 | case $1 in
12 | # documents
13 | -txt)
14 | opt='text/';;
15 | -pdf)
16 | opt='pdf' ;;
17 | -office)
18 | opt='vnd\.openxmlformats\-officedocument' ;;
19 |
20 | # compressed
21 | -zip)
22 | opt='zip';;
23 | -rar)
24 | opt='x\-rar' ;;
25 |
26 | # executables
27 | -pe)
28 | opt='(x\-dosexec|vnd\.microsoft\.portable\-executable)' ;;
29 | -msi)
30 | opt='vnd\.ms\-office' ;;
31 | -macho)
32 | opt='x\-mach\-binary' ;;
33 | -elf)
34 | opt='x\-(executable|pie\-executable|sharedlib)' ;;
35 | *)
36 | return
37 | esac
38 |
39 | # buffering results
40 | matches=$(for i in "$dir"/*; do
41 | filetype=$(file -Nb --mime-type "$i")
42 | [[ "$filetype" =~ application/$opt ]] && echo "${i#./*}"
43 | done)
44 |
45 | [[ -n "$matches" ]] && echo "$matches" | tr -s / /
46 | }
47 |
--------------------------------------------------------------------------------
/src/filesystem/bh_hashes.sh:
--------------------------------------------------------------------------------
1 | bh_hashes() {
2 | (( $# < 1 )) && return 1
3 |
4 | local i
5 |
6 | for i in $*; do
7 | echo $(bh_cmd_md5 "$i")
8 | echo $(bh_cmd_sha1 "$i")
9 | echo $(bh_cmd_sha256 "$i")
10 | done | tr -s ' ' ' '
11 | }
12 |
--------------------------------------------------------------------------------
/src/filesystem/bh_md5rename.sh:
--------------------------------------------------------------------------------
1 | bh_md5rename() {
2 | (( $# < 1 )) && return 1
3 |
4 | local md5_hash
5 | local i
6 |
7 | for i in $*; do
8 | md5_hash=$(bh_cmd_md5 "$i" | cut -d" " -f1)
9 | [[ $md5_hash ]] && mv -v "$i" $(dirname "$i")/$md5_hash
10 | done
11 | }
12 |
--------------------------------------------------------------------------------
/src/filesystem/bh_secretfile.sh:
--------------------------------------------------------------------------------
1 | bh_secretfile(){
2 | (( $# < 1 )) && return 1
3 |
4 | local pw=$(tr -dc "a-zA-Z0-9_#@.-" < /dev/urandom | head -c 20)
5 | local filename=$RANDOM.zip
6 | zip -P "$pw" "$filename" "$1"
7 | echo "password: $pw"
8 | rm -f "$filename"
9 | }
10 |
--------------------------------------------------------------------------------
/src/filesystem/bh_sharefile.sh:
--------------------------------------------------------------------------------
1 | bh_sharefile() {
2 | (( $# < 1 )) && return 1
3 |
4 | curl -sF "file=@$1" https://file.io | grep -o 'https://file\.io/[a-zA-Z0-9]*'
5 | }
6 |
--------------------------------------------------------------------------------
/src/filesystem/bh_zipmal.sh:
--------------------------------------------------------------------------------
1 | bh_zipmal() {
2 | (( $# < 1 )) && return 1
3 |
4 | local name=${1%\.*}.zip
5 | zip --encrypt -P infected "$name" $@
6 | ls -lh "$name"
7 | echo "password: infected"
8 | }
9 |
--------------------------------------------------------------------------------
/src/internal/bashacks.sh:
--------------------------------------------------------------------------------
1 | bashacks() {
2 | echo -e "This is not how you use it. Type bh_ and press instead."
3 | }
4 |
--------------------------------------------------------------------------------
/src/internal/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | bashacks_config="$HOME/.config/bashacks"
4 | bashacks_cachedir="$bashacks_config/cache"
5 | bashacks_os=$(uname -s)
6 | bashacks_wget_user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246"
7 |
8 | if [[ $bashacks_os = 'Darwin' ]]; then
9 | alias bh_cmd_md5='md5 -r'
10 | alias bh_cmd_sha1='shasum'
11 | alias bh_cmd_sha256='shasum -a256'
12 | alias bh_cmd_sha512='shasum -a512'
13 | alias bh_cmd_disasm='objdump -d --x86-asm-syntax=intel'
14 | alias bh_cmd_sed_ext='sed -E'
15 | else # assume Linux
16 | alias bh_cmd_md5='md5sum'
17 | alias bh_cmd_sha1='sha1sum'
18 | alias bh_cmd_sha256='sha256sum'
19 | alias bh_cmd_sha512='sha512sum'
20 | alias bh_cmd_disasm='objdump -dM intel'
21 | alias bh_cmd_sed_ext='sed -r'
22 | fi
23 |
24 | alias bh_rot13='bh_rot 13'
25 |
26 |
--------------------------------------------------------------------------------
/src/math/bh_bin2dec.sh:
--------------------------------------------------------------------------------
1 | bh_bin2dec() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo $((2#$1))
5 | }
6 |
--------------------------------------------------------------------------------
/src/math/bh_charcalc.sh:
--------------------------------------------------------------------------------
1 | bh_charcalc() {
2 | (( $# < 3 )) && return 1
3 |
4 | local char
5 | local chars
6 | local res
7 | local i
8 |
9 | case $2 in
10 | +|-)
11 | for i in $(echo "$1" | sed 's/./& /g'); do
12 | char=$(bh_str2dec $i)
13 | res=$(($char $2 $3))
14 | echo -n $(bh_dec2asc $res)
15 | done
16 | echo
17 | ;;
18 | '*')
19 | for (( i=0; i<$3; i++ )); do
20 | res="$res$1"
21 | done
22 | echo $res
23 | ;;
24 | esac
25 | }
26 |
--------------------------------------------------------------------------------
/src/math/bh_dec2bin.sh:
--------------------------------------------------------------------------------
1 | bh_dec2bin() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo "obase=2;$1" | bc
5 | }
6 |
--------------------------------------------------------------------------------
/src/math/bh_dec2hex.sh:
--------------------------------------------------------------------------------
1 | bh_dec2hex() {
2 | (( $# < 1 )) && return 1
3 |
4 | printf "%x\n" "$1"
5 | }
6 |
--------------------------------------------------------------------------------
/src/math/bh_hex2bin.sh:
--------------------------------------------------------------------------------
1 | bh_hex2bin() {
2 | (( $# < 1 )) && return 1
3 |
4 | local bin
5 | local i
6 |
7 | for i in $*; do
8 | bin=$(echo "obase=2;ibase=16;$(echo $i | tr a-f A-F)" | bc)
9 | echo -n "$bin "
10 | done
11 | echo
12 | }
13 |
--------------------------------------------------------------------------------
/src/math/bh_hex2dec.sh:
--------------------------------------------------------------------------------
1 | bh_hex2dec() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo $(( 0x${1#0x} ))
5 | }
6 |
--------------------------------------------------------------------------------
/src/math/bh_hexcalc.sh:
--------------------------------------------------------------------------------
1 | bh_hexcalc() {
2 | (( $# < 3 )) && return 1
3 |
4 | echo -n 0x
5 | bh_dec2hex $((0x${1#0x} $2 0x${3#0x}))
6 | }
7 |
--------------------------------------------------------------------------------
/src/misc/bh_epoch.sh:
--------------------------------------------------------------------------------
1 | bh_epoch() {
2 | (( $# == 0 )) && ( date +%s; return; )
3 |
4 | if [[ $1 =~ ^[0-9]+$ ]]; then
5 | [[ $bashacks_os == Darwin ]] && date -ur $1 || date -d @$1
6 | fi
7 | }
8 |
--------------------------------------------------------------------------------
/src/net/bh_bin2ip.sh:
--------------------------------------------------------------------------------
1 | bh_bin2ip() {
2 | (( $# < 1 )) && return 1
3 |
4 | local a=b=c=d=
5 |
6 | IFS=. read a b c d <<< "$1"
7 | echo $((2#$a)).$((2#$b)).$((2#$c)).$((2#$d))
8 | }
9 |
--------------------------------------------------------------------------------
/src/net/bh_hostcalc.sh:
--------------------------------------------------------------------------------
1 | bh_hostcalc() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo $((2**(32-$1) - 2))
5 | }
6 |
--------------------------------------------------------------------------------
/src/net/bh_ip2bin.sh:
--------------------------------------------------------------------------------
1 | bh_ip2bin() {
2 | [[ "$1" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]] || return 1
3 |
4 | local i
5 | for i in $(echo "$1" | tr . ' '); do
6 | printf "%.8d." $(bh_dec2bin $i)
7 | done | sed "s/.$//"
8 | echo
9 | }
10 |
--------------------------------------------------------------------------------
/src/net/bh_ipinfo.sh:
--------------------------------------------------------------------------------
1 | bh_ipinfo()
2 | {
3 | local ipaddress="${1:-`bh_myip`}"
4 | local url="http://ipinfo.io"
5 |
6 | wget -qO - "$url/$ipaddress"
7 | }
8 |
--------------------------------------------------------------------------------
/src/net/bh_ipisblocked.sh:
--------------------------------------------------------------------------------
1 | bh_ipisblocked() {
2 | (( $# < 1 )) && return 1
3 |
4 | local ipaddress="${1:-`bh_myip`}"
5 | local url_projects='TALOS;https://www.talosintelligence.com/documents/ip-blacklist
6 | Malc0de;http://malc0de.com/bl/IP_Blacklist.txt
7 | Projecthoneypot.org;https://www.projecthoneypot.org/list_of_ips.php
8 | blocklist.de;http://lists.blocklist.de/lists/all.txt
9 | Alienvault;https://reputation.alienvault.com/reputation.generic
10 | SANS-TOPSOURCE;https://isc.sans.edu/api/topsources?json'
11 |
12 | echo "== $ipaddress =="
13 | for project in $url_projects; do
14 | pjname="$(echo $project \
15 | | cut -d ';' -f1)"
16 | pjlink="$(echo $project \
17 | | cut -d ';' -f2)"
18 |
19 | if wget -T10 $pjlink -q -O - \
20 | | grep -Eo "([0-9]{1,3}\.){3}[0-9]{1,3}" \
21 | | grep -E ^$ipaddress$ > /dev/null 2>&1
22 | then
23 | echo -e "[T]\t$pjname"
24 | else
25 | echo -e "[F]\t$pjname"
26 | fi
27 | done
28 | }
29 |
--------------------------------------------------------------------------------
/src/net/bh_myip.sh:
--------------------------------------------------------------------------------
1 | bh_myip() {
2 | local ip=$(wget -q https://api.ipify.org -O -)
3 | [[ $ip =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]] && echo $ip
4 | }
--------------------------------------------------------------------------------
/src/net/bh_unshort.sh:
--------------------------------------------------------------------------------
1 | bh_unshort() {
2 | (( $# < 1 )) && return 1
3 |
4 | wget -T10 --max-redirect 0 --spider "$1" 2>&1 | grep -E '^Loca(tion|liza..o):' | cut -d' ' -f2
5 | }
6 |
--------------------------------------------------------------------------------
/src/net/bh_wgetr.sh:
--------------------------------------------------------------------------------
1 | bh_wgetr() {
2 | (( $# < 1 )) && return 1
3 |
4 | wget -crw 2 --random-wait -U "$bashacks_wget_user_agent" "$1"
5 | }
--------------------------------------------------------------------------------
/src/programming/bh_skel_c.sh:
--------------------------------------------------------------------------------
1 | bh_skel_c() {
2 | echo -e "#include \n\nint main(int argc, char *argv[]) {\n\n\n\treturn 0;\n}"
3 | }
4 |
--------------------------------------------------------------------------------
/src/programming/bh_skel_go.sh:
--------------------------------------------------------------------------------
1 | bh_skel_go(){
2 | echo -e "package main\n\nimport (\n\t\"fmt\"\n)\n\nfunc main() {\n\n\tfmt.Println(\"test\")\n\n}"
3 | }
4 |
--------------------------------------------------------------------------------
/src/programming/bh_skel_latex.sh:
--------------------------------------------------------------------------------
1 | bh_skel_latex(){
2 | echo -e \
3 | '\\documentclass{article}
4 |
5 | \\usepackage[english]{babel}
6 | \\usepackage[utf8]{inputenc}
7 | \\usepackage[margin=1in]{geometry}
8 |
9 | \\author{}
10 | \\title{}
11 |
12 | \\begin{document}
13 | \\maketitle
14 |
15 | \\end{document}'
16 | }
17 |
--------------------------------------------------------------------------------
/src/programming/bh_skel_python.sh:
--------------------------------------------------------------------------------
1 | bh_skel_python() {
2 | echo -e "#!/usr/bin/env python\n# *-* coding: utf-8 *-*\n\nif __name__ == "__main__":\n\t"
3 | }
--------------------------------------------------------------------------------
/src/programming/bh_skel_yara.sh:
--------------------------------------------------------------------------------
1 | bh_skel_yara() {
2 | echo -e \
3 | "rule test {
4 | meta:
5 | author = \"$(whoami)\"
6 | description = \"\"
7 | date = \"$(date +%Y-%m-%d)\"
8 | ref = \"\"
9 | hash = \"\"
10 |
11 | strings:
12 | \$a = \"test\" ascii wide
13 |
14 | condition:
15 | all of them
16 | }"
17 | }
18 |
--------------------------------------------------------------------------------
/src/reversing/bh_asmgrep.sh:
--------------------------------------------------------------------------------
1 | bh_asmgrep() {
2 | (( $# < 2 )) && return 1
3 |
4 | bh_cmd_disasm "$2" | grep --color -EC4 "$1"
5 | }
6 |
--------------------------------------------------------------------------------
/src/reversing/bh_asminfo.sh:
--------------------------------------------------------------------------------
1 | bh_asminfo() {
2 | (( $# < 1 )) && return 1
3 |
4 | local ins=$1
5 |
6 | [[ -d $bashacks_cachedir ]] || mkdir -p $bashacks_cachedir
7 |
8 | if [[ -s $bashacks_cachedir/$ins.txt ]]; then
9 | cat $bashacks_cachedir/$ins.txt
10 | else
11 | wget -T10 -U "${bashacks_wget_user_agent}" \
12 | -q https://faydoc.tripod.com/cpu/$ins.htm -O - \
13 | | html2text \
14 | | sed -n '/^===.*/,$p' \
15 | | sed 's/^===.*/'${ins}'/;s/_/ /g' \
16 | | tee -a $bashacks_cachedir/$ins.txt
17 | fi
18 | }
19 |
--------------------------------------------------------------------------------
/src/reversing/bh_replacestring.sh:
--------------------------------------------------------------------------------
1 | bh_replacestring() {
2 | [[ -f "$1" && -n "$2" && -n "$3" && "${#2}" == "${#3}" ]] || return 1
3 |
4 | local fil="$1"
5 | local src="$2"
6 | local dst="$3"
7 |
8 | local srchex=$(echo "$src" | xxd -pu)
9 | local dsthex=$(echo "$dst" | xxd -pu)
10 |
11 | local tmpfile=$(mktemp)
12 |
13 | # xxd -r -p works, while xxd -rp or xxd -pr doesn't O.o
14 | xxd -p $fil | tr -d \\n | sed "s/${srchex::-2}/${dsthex::-2}/g" | xxd -r -p > $tmpfile
15 |
16 | [[ -s $tmpfile ]] && mv $tmpfile $fil
17 | }
18 |
--------------------------------------------------------------------------------
/src/reversing/bh_zerostring.sh:
--------------------------------------------------------------------------------
1 | bh_zerostring() {
2 | [[ -f "$1" && -n "$2" ]] || return 1
3 |
4 | local fil="$1"
5 | local search="$2"
6 |
7 | # 'tr' is needed here because the strings command
8 | # might output lines starting with two spaces
9 | local pos=$(strings -t d "$fil" | grep -F "$search" | tr -s ' ' ' ' | cut -d' ' -f1)
10 |
11 | local siz=${#search}
12 | for i in $pos; do
13 | dd conv=notrunc bs=1 count=$siz seek=$i if=/dev/zero of="$fil"
14 | done
15 | }
16 |
--------------------------------------------------------------------------------
/src/strings/bh_asciitable.sh:
--------------------------------------------------------------------------------
1 | bh_asciitable() {
2 | echo -en \
3 | "Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex\n\
4 | 0 00 NUL 16 10 DLE 32 20 48 30 0 64 40 @ 80 50 P 96 60 \` 112 70 p\n\
5 | 1 01 SOH 17 11 DC1 33 21 ! 49 31 1 65 41 A 81 51 Q 97 61 a 113 71 q\n\
6 | 2 02 STX 18 12 DC2 34 22 \" 50 32 2 66 42 B 82 52 R 98 62 b 114 72 r\n\
7 | 3 03 ETX 19 13 DC3 35 23 # 51 33 3 67 43 C 83 53 S 99 63 c 115 73 s\n\
8 | 4 04 EOT 20 14 DC4 36 24 $ 52 34 4 68 44 D 84 54 T 100 64 d 116 74 t\n\
9 | 5 05 ENQ 21 15 NAK 37 25 % 53 35 5 69 45 E 85 55 U 101 65 e 117 75 u\n\
10 | 6 06 ACK 22 16 SYN 38 26 & 54 36 6 70 46 F 86 56 V 102 66 f 118 76 v\n\
11 | 7 07 BEL 23 17 ETB 39 27 ' 55 37 7 71 47 G 87 57 W 103 67 g 119 77 w\n\
12 | 8 08 BS 24 18 CAN 40 28 ( 56 38 8 72 48 H 88 58 X 104 68 h 120 78 x\n\
13 | 9 09 HT 25 19 EM 41 29 ) 57 39 9 73 49 I 89 59 Y 105 69 i 121 79 y\n\
14 | 10 0A LF 26 1A SUB 42 2A * 58 3A : 74 4A J 90 5A Z 106 6A j 122 7A z\n\
15 | 11 0B VT 27 1B ESC 43 2B + 59 3B ; 75 4B K 91 5B [ 107 6B k 123 7B {\n\
16 | 12 0C FF 28 1C FS 44 2C , 60 3C < 76 4C L 92 5C \\ 108 6C l 124 7C |\n\
17 | 13 0D CR 29 1D GS 45 2D - 61 3D = 77 4D M 93 5D ] 109 6D m 125 7D }\n\
18 | 14 0E SO 30 1E RS 46 2E . 62 3E > 78 4E N 94 5E ^ 110 6E n 126 7E ~\n\
19 | 15 0F SI 31 1F US 47 2F / 63 3F ? 79 4F O 95 5F _ 111 6F o 127 7F DEL\n"
20 | }
21 |
--------------------------------------------------------------------------------
/src/strings/bh_dec2asc.sh:
--------------------------------------------------------------------------------
1 | bh_dec2asc() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo -e $(printf "\\\x%x" $1)
5 | }
6 |
--------------------------------------------------------------------------------
/src/strings/bh_hex2str.sh:
--------------------------------------------------------------------------------
1 | bh_hex2str() {
2 | (( $# < 1 )) && return 1
3 |
4 | local hex
5 | local i
6 |
7 | # remove non-hexa characters
8 | hex=$(echo "$1" | bh_cmd_sed_ext 's/(0x|\\x| |\{|\||\}|,)//g')
9 |
10 | # insert space every two characters
11 | hex=$(echo "$hex" | bh_cmd_sed_ext 's/../& /g')
12 |
13 | for i in $hex; do
14 | echo -ne "\\x$i"
15 | done
16 | echo
17 | }
18 |
--------------------------------------------------------------------------------
/src/strings/bh_str2dec.sh:
--------------------------------------------------------------------------------
1 | bh_str2dec() {
2 | (( $# < 1 )) && return 1
3 |
4 | echo -n "$1" | hexdump -ve '/1 "%d "' | sed 's/\(.*\) /\1/'
5 | echo
6 | }
7 |
8 | bh_asc2dec() {
9 | echo "WARNING: bh_asc2dec() is depcreated and will be removed in the next release. Use bh_str2dec() instead."
10 | (( $# < 1 )) && return 1
11 |
12 | bh_str2dec $1
13 | }
14 |
--------------------------------------------------------------------------------
/src/strings/bh_str2hex.sh:
--------------------------------------------------------------------------------
1 | bh_str2hex() {
2 | (( $# < 1 )) && return 1
3 |
4 | case "$1" in
5 | "-x")
6 | echo -n "$2" | hexdump -ve '/1 "%02x"' | sed 's/../\\x&/g'
7 | echo
8 | ;;
9 | "-0x")
10 | echo -n "$2" | hexdump -ve '/1 "0x%02x "' | sed 's/\(.*\) /\1/'
11 | echo
12 | ;;
13 | "-c")
14 | echo -n '{ '
15 | echo -n "$2" | hexdump -ve '/1 "0x%02x, "' | sed 's/\(.*\), /\1/'
16 | echo ' }'
17 | ;;
18 | *)
19 | echo -n "$1" | hexdump -ve '/1 "%02x "' | sed 's/\(.*\) /\1/'
20 | echo
21 | ;;
22 | esac
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/src/strings/bh_str2hexr.sh:
--------------------------------------------------------------------------------
1 | bh_str2hexr() {
2 | (( $# < 1 )) && return 1
3 |
4 | case "$1" in
5 | "-x" | "-0x" | "-c")
6 | bh_str2hex $1 "$(echo "$2" | rev)"
7 | ;;
8 | *)
9 | bh_str2hex "$(echo "$1" | rev)"
10 | ;;
11 | esac
12 | }
13 |
--------------------------------------------------------------------------------
/src/strings/bh_urldecode.sh:
--------------------------------------------------------------------------------
1 | bh_urldecode() {
2 | (( $# < 1 )) && return 1
3 | echo "$1" | perl -pe 's/%([0-9a-f]{2})/pack "H*", $1/gie'
4 | }
--------------------------------------------------------------------------------
/src/strings/bh_urlencode.sh:
--------------------------------------------------------------------------------
1 | bh_urlencode() {
2 | (( $# < 1 )) && return 1
3 | echo -ne "$1" | perl -pe 's/\W/"%".unpack "H*",$&/gei'
4 | echo
5 | }
--------------------------------------------------------------------------------
/src/strings/bh_utf8table.sh:
--------------------------------------------------------------------------------
1 | bh_utf8table() {
2 | echo -ne \
3 | "Hex Hex Hex Hex Hex Hex Hex Hex\n\
4 | c2 a0 c2 ac ¬ c2 b8 ¸ c3 84 Ä c3 90 Ð c3 9c Ü c3 a8 è c3 b4 ô\n\
5 | c2 a1 ¡ c2 ad c2 b9 ¹ c3 85 Å c3 91 Ñ c3 9d Ý c3 a9 é c3 b5 õ\n\
6 | c2 a2 ¢ c2 ae ® c2 ba º c3 86 Æ c3 92 Ò c3 9e Þ c3 aa ê c3 b6 ö\n\
7 | c2 a3 £ c2 af ¯ c2 bb » c3 87 Ç c3 93 Ó c3 9f ß c3 ab ë c3 b7 ÷\n\
8 | c2 a4 ¤ c2 b0 ° c2 bc ¼ c3 88 È c3 94 Ô c3 a0 à c3 ac ì c3 b8 ø\n\
9 | c2 a5 ¥ c2 b1 ± c2 bd ½ c3 89 É c3 95 Õ c3 a1 á c3 ad í c3 b9 ù\n\
10 | c2 a6 ¦ c2 b2 ² c2 be ¾ c3 8a Ê c3 96 Ö c3 a2 â c3 ae î c3 ba ú\n\
11 | c2 a7 § c2 b3 ³ c2 bf ¿ c3 8b Ë c3 97 × c3 a3 ã c3 af ï c3 bb û\n\
12 | c2 a8 ¨ c2 b4 ´ c3 80 À c3 8c Ì c3 98 Ø c3 a4 ä c3 b0 ð c3 bc ü\n\
13 | c2 a9 © c2 b5 µ c3 81 Á c3 8d Í c3 99 Ù c3 a5 å c3 b1 ñ c3 bd ý\n\
14 | c2 aa ª c2 b6 ¶ c3 82 Â c3 8e Î c3 9a Ú c3 a6 æ c3 b2 ò c3 be þ\n\
15 | c2 ab « c2 b7 · c3 83 Ã c3 8f Ï c3 9b Û c3 a7 ç c3 b3 ó c3 bf ÿ\n"
16 | }
--------------------------------------------------------------------------------