2015-04-28 22:03:21 -04:00
|
|
|
#!/usr/bin/env python
|
2015-04-29 18:18:16 -04:00
|
|
|
import os, argparse, socket, sys, struct, easygui
|
2015-05-01 17:05:22 -04:00
|
|
|
import tkinter.messagebox, tkinter.filedialog
|
2015-04-17 22:20:13 -04:00
|
|
|
|
2015-04-29 18:11:06 -04:00
|
|
|
# New & improved args parsing
|
|
|
|
parser = argparse.ArgumentParser(description='Sends .CIA files to the 3DS via FBI')
|
|
|
|
parser.add_argument('-c', '--cia', help='.CIA rom file', metavar='FILE', required=False, nargs=1)
|
|
|
|
parser.add_argument('-i', '--ip', help='The IP address of the target 3DS (e.g. 192.168.1.123)', metavar='STRING',
|
|
|
|
required=False, nargs=1)
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
# Ask for the desired .CIA file if none is given
|
|
|
|
if args.cia:
|
|
|
|
cia = args.cia[0]
|
|
|
|
else:
|
2015-05-01 17:05:22 -04:00
|
|
|
cia = tkinter.filedialog.askopenfilename(title="Falcon Punch - Choose CIA to Send", initialdir="/",
|
|
|
|
defaultextension=".cia", filetypes=[("CIA File", "*.cia")], multiple=False)
|
2015-04-29 18:11:06 -04:00
|
|
|
|
|
|
|
statinfo = os.stat(cia)
|
2015-04-17 22:20:13 -04:00
|
|
|
fbiinfo = struct.pack('!q', statinfo.st_size)
|
|
|
|
|
2015-04-29 18:11:06 -04:00
|
|
|
# Asks for the IP address of the 3DS if none is given
|
|
|
|
if args.ip:
|
|
|
|
dsip = args.ip[0]
|
|
|
|
else:
|
|
|
|
dsip = easygui.enterbox("Enter 3DS' IP:", "FalconPunch", "192.168.1.1")
|
|
|
|
|
|
|
|
file = open(cia, "rb")
|
2015-04-17 22:20:13 -04:00
|
|
|
sock = socket.socket()
|
|
|
|
sock.connect((dsip, 5000))
|
|
|
|
|
|
|
|
sock.send(fbiinfo)
|
|
|
|
|
2015-04-29 18:11:06 -04:00
|
|
|
# Sends the each chunk of the .CIA till there is nothing left
|
2015-04-17 22:20:13 -04:00
|
|
|
while True:
|
|
|
|
chunk = file.read(16384)
|
|
|
|
if not chunk:
|
2015-04-29 18:11:06 -04:00
|
|
|
# Prints or displays a confirmation based on how the program is given info
|
|
|
|
confirmation = "Sent " + cia + " to the 3DS (" + dsip + ")"
|
|
|
|
if args.cia and args.ip:
|
|
|
|
print(confirmation)
|
|
|
|
else:
|
2015-05-01 16:44:31 -04:00
|
|
|
tkinter.messagebox.showinfo("Falcon Punch", confirmation)
|
2015-04-17 22:20:13 -04:00
|
|
|
break # EOF
|
|
|
|
sock.sendall(chunk)
|
|
|
|
|
|
|
|
sock.close()
|
|
|
|
sys.exit()
|