forked from attify/firmware-analysis-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.py
36 lines (28 loc) · 1.21 KB
/
reset.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
#!/usr/bin/env python2.7
import pexpect
# Change the root password according to your system
root_pass = "root"
firm_pass = "firmadyne"
print
print "[+] Deleting existing database with the name firmware"
child = pexpect.spawn("psql -d postgres -U firmadyne -h 127.0.0.1 -q -c 'DROP DATABASE \"firmware\"'")
child.expect("Password for user firmadyne: ")
child.sendline(firm_pass)
child.expect(pexpect.EOF)
print "[+] Creating new database with firmware with the user firmadyne"
child = pexpect.spawn("sudo -u postgres createdb -O firmadyne firmware")
child.sendline(root_pass)
child.expect(pexpect.EOF)
print "[+] Making necessary changes to the db"
child = pexpect.spawn("/bin/sh", ["-c", "sudo -u postgres psql -d firmware < ./database/schema"])
child.sendline(root_pass)
child.expect(pexpect.EOF)
print "[+] Cleaning previous images and created files by firmadyne"
child = pexpect.spawn("/bin/sh", ["-c", "sudo rm -rf ./images/*.tar.gz"])
child.sendline(root_pass)
child.expect(pexpect.EOF)
child = pexpect.spawn("sudo rm -rf scratch/")
child.sendline(root_pass)
child.expect(pexpect.EOF)
print "[+] All done. Go ahead and run fat.py to continue firmware analysis"
print " Remember the password for the database is firmadyne\n"