Subversion Repositories freemyipod

Rev

Rev 253 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
253 theseven 1
#!/usr/bin/env python
2
#
3
#
4
#    Copyright 2010 TheSeven
5
#
6
#
7
#    This file is part of emBIOS.
8
#
9
#    emBIOS is free software: you can redistribute it and/or
10
#    modify it under the terms of the GNU General Public License as
11
#    published by the Free Software Foundation, either version 2 of the
12
#    License, or (at your option) any later version.
13
#
14
#    emBIOS is distributed in the hope that it will be useful,
15
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
#    See the GNU General Public License for more details.
18
#
19
#    You should have received a copy of the GNU General Public License along
20
#    with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
21
#
22
#
23
 
24
 
25
import sys
26
import os
27
import struct
28
 
29
if not os.path.exists(sys.path[0] + "/uclstub/build/uclstub.bin"):
30
    os.system("make -C " + sys.path[0] + "/uclstub")
31
 
32
if not os.path.exists(sys.path[0] + "/ftlstub/build/ftlstub.ucl"):
33
    os.system("make -C " + sys.path[0] + "/ftlstub")
34
 
35
file = open(sys.argv[1], "rb")
36
payload = file.read()
37
file.close()
38
 
39
file = open(sys.path[0] + "/uclstub/build/uclstub.bin", "rb")
40
uclstub = file.read()
41
file.close()
42
 
43
file = open(sys.path[0] + "/ftlstub/build/ftlstub.ucl", "rb")
44
ftlstub = file.read()
45
file.close()
46
 
254 theseven 47
exploit = "<a href=\"" + sys.argv[2].ljust(276) + "%34%05%64%08\">a</a>"
253 theseven 48
 
49
file = open(sys.argv[3], "wb")
50
file.write(exploit + ftlstub.ljust(4096 - len(exploit) - len(uclstub), "\0") + uclstub + payload)
51
file.close()