Skip to content

Commit

Permalink
add bfg_fabric.py
Browse files Browse the repository at this point in the history
  • Loading branch information
govolution committed Feb 9, 2018
1 parent 50e6e0f commit 4485ea2
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions bfg_fabric.py
@@ -0,0 +1,76 @@
#!/usr/bin/python3
# Author: Daniel Sauder
# License: https://www.gnu.org/licenses/gpl.txt or LICENSE file
# Web: https://github.com/govolution/avet

import glob, os, readline
import subprocess, stat

banner = """
________ ________ ________
|\ __ \|\ _____\\ ____\
\ \ \|\ /\ \ \__/\ \ \___|
\ \ __ \ \ __\\ \ \ ___
\ \ \|\ \ \ \_| \ \ \|\ \
\ \_______\ \__\ \ \_______\
\|_______|\|__| \|_______|
Binary Fancy Generator Fabric by Daniel Sauder
"""

def rlinput(prompt, prefill=''):
readline.set_startup_hook(lambda: readline.insert_text(prefill))
try:
return input(prompt)
finally:
readline.set_startup_hook()


print(banner)
print("bfg_fabric.py is an assistant for building exe files with the purpose of (shell-)code execution, injection and more.\n")

# read and print build scripts
file_counter=0;
file_list = []
os.chdir("./build")
for file in glob.glob("build*.sh"):
print(str(file_counter)+": "+file)
file_list.append(file)
file_counter+=1

choice=input("Input number of the script you want use and hit enter: ")
fname=file_list[int(choice)]

print("\nNow you can edit the build script line by line.\n")
commands=[]
commands.append("#/bin/bash")
# read the build scipt
with open(fname) as fi:
for line in fi:
line=line.rstrip()
if line[0:2]!="#!" and line[0]=="#":
print(line.lstrip('#').lstrip())
elif line[0:2]!="#!":
cmd=rlinput("$ ", line)
commands.append(cmd)

print("\nThe following commands will be executed:")

for cmd in commands:
print(cmd)

input("\nPress enter to continue.")

os.chdir("..")
with open("build/tmpbuildscript.sh", mode="w") as f:
f.write('\n'.join(commands))


print("\nBuilding the output file...\n\nPlease stand by...")
st = os.stat('./build/tmpbuildscript.sh')
os.chmod('./build/tmpbuildscript.sh', st.st_mode | stat.S_IEXEC)
subprocess.check_output(['/bin/bash','./build/tmpbuildscript.sh'], stderr=subprocess.STDOUT)
os.remove('./build/tmpbuildscript.sh')

print("\nThe output file should be placed in the current directory.\n\nBye...")

0 comments on commit 4485ea2

Please sign in to comment.