-
Notifications
You must be signed in to change notification settings - Fork 7
/
bfg_fabric.py
executable file
·76 lines (59 loc) · 2.01 KB
/
bfg_fabric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python3
# Author: Daniel Sauder
# License: https://www.gnu.org/licenses/gpl.txt or LICENSE file
# Web: https:/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...")