GithubHelp home page GithubHelp logo

merces / bashacks Goto Github PK

View Code? Open in Web Editor NEW
197.0 197.0 45.0 338 KB

A set of functions to increase productivity while hacking with Bash

License: GNU General Public License v3.0

Makefile 4.08% Shell 95.92%
bash-hacks command-line malware-analysis oneliners

bashacks's Introduction

bashacks's People

Contributors

atcasanova avatar ephiguxta avatar fadamiao avatar hc0d3r avatar j3r3mias avatar leandrofroes avatar mariomoura avatar merces avatar nilsonfsilva avatar traleski avatar wesleyleite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bashacks's Issues

bh_strxor have a bug

$ bh_strxor 15 'hack'

sed: -e expression #1, char 22: Invalid preceding regular expression

this bug may be related to bh_hex2str script, look this:

$ set -x
$ bh_strxor 15 'hack'

. . .

+ bh_hex2str ' 67 6e 6c 64'
+ [[ 1 -ne 1 ]]
+ local hex
+ local oIFS
+ local i
++ echo ' 67 6e 6c 64'
++ sed -r 's/(0x|\\x| |{\|}|,)//g'
sed: -e expression #1, char 22: Invalid preceding regular expression

Create delivery continuous

I would like to make a PKGBUILD and make available in the AUR however the most stable way would be to pull the releases, but it is interesting to create a DC. What do you think?

Split manpage by function

The goal is to better organize this area, because, today is very confusing and difficult maintenance

doc update

I'll be working on updating all the documentation "next week"...
any comment, send below...

new function ispunct()

check whether the char is punctuation,
basically is 'isgraph()' that is not alphanumeric.

Why deliver those codes as functions?

I think using functions and embedding them in .bash_profile puts a lot of pressure on the environment space. Why not to use plain shell scripts? It would be as easy to install and be made globally available as:

$ find ./ -type f -name 'bh_*' -exec cp "{}" /usr/local/bin/ \;

Due to bh_ prefix, this cannot give us any problems with colliding filenames (since 'bh_' can be seen as a namespace). And I would get rid of .sh filename extension as well...

Take a look at a modified version of bh_hashcrack, for instance (of course, there is a minor problem here if wget fails).

#!/bin/bash
# vim: set ts=2 sw=2 et:

# NOTICE: I'm using ANSI to colorize some messages.

# We need a single parameter for this script. Ignore the rest, if any.
if [ -z "${1}" ]
then
  echo -e "\e[33;1mUsage\e[0m: bh_hashcrack <hash>\n"
  exit 1
fi

# If it isn't an hexadecimal string...
if [ ! -z "$(sed -n '/[^0-9A-Fa-f]/p' <<< "${1}")" ]
then
  echo -e "\e[31;1mERROR\e[0m: Invalid hash format."
  exit 1
fi

BH_SITE="http://hashtoolkit.com/reverse-hash/?hash=${1}"

# FIXME: Is this the best method?
BH_DATA="$(wget -qO - "${BH_SITE}")"

# if wget didn't fail, this substring is present on the result string!
if grep -qF 'No hashes found' <<< "${BH_DATA}"
then
  echo -e "\e[31;1mERROR\e[0m: No hashes found."
  exit 1
fi

BH_RES=$(echo "${BH_DATA}" \
 | grep -FA1 'res-text' \
 | sed -n 's/^.*<span>\(.*\)<\/span>.*$/\1/p')

if [ "${BH_RES}" != "${1}" ]
then
  echo -e "\e[33;1mFound\e[0m:"
  echo "${BH_RES}" | sort -u
fi

Notice the renaming of 'local' vars, now uppercase and prefixed with BH_. "Local" because they are not exported.

PS: Of course, if multiple hashes could be used as arguments, we can, always, use a loop with $@ var.
PS2: It should be clear that I don't like some bash/shell scripts shortcuts as well... :)

[]s
Fred

new function isspace()

check whether the char is white-space

' ' (0x20) space (SPC)
'\t' (0x09) horizontal tab (TAB)
'\n' (0x0a) newline (LF)
'\v' (0x0b) vertical tab (VT)
'\f' (0x0c) feed (FF)
'\r' (0x0d) carriage return (CR)

coding style

how about we create a configuration file in the repository to standardize the indentation?
[like this]

Question about bash strict/portable/valid syntax

I saw you write some $() bash expressions without nested double quotes:

matches=$(for i in "$dir"/*; do
filetype=$(file -Nb --mime-type "$i")
[[ "$filetype" =~ application/$opt ]] && echo "${i#./*}"
done)

local pos=$(strings -t d "$fil" | grep -F "$search" | tr -s ' ' ' ' | cut -d' ' -f2)
siz=${#search}
for i in $pos; do
[[ $i -gt 0 ]] || continue
dd conv=notrunc bs=1 count=$siz seek=$i if=/dev/zero of="$fil"
done

cache=$(grep "${hash}:" "${BASHACKS_CACHEDIR}/hash")
if [[ "$cache" ]]; then

It might be not much important in particular code. But there is some discussion exists:

https://stackoverflow.com/questions/68588306/nested-double-quotes-in-bash-scripts
https://unix.stackexchange.com/questions/289574/nested-double-quotes-in-assignment-with-command-substitution

Why not just always put the output into nested double quotes:

myvar="$(... "...")"

Isn't that more safer and faster (command line substitution is skipped)?

I've found that the absence of nested double quotes just gives you random errors dependent on the output and context. So better to just always use the nested double quotes to avoid that.

On another hand, there is a fork with quite opposite fixes:

1d1e93d#r86797412

Build wiki.

Wiki with information of each function I/O examples, the propose of project, code style, standards and more.

Add support for OS X

Correct if I'm wrong but recent OS X versions have Bash by default. We could easily extend bashacks to support OS X version of Linux commands, as I did on 1f7efcf for bh_md5reanme() function. What do you say @wesleyleite? That may require us to remove some functions, but I suspect some functions like dumpmem() or asm2sc() are rarely used anyway. We must apply KISS methodology here. ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.