def main(argv): # Parse options import argparse parser = argparse.ArgumentParser() group = parser.add_argument_group("upstream options") group.add_argument("-c", "--connect", dest="connect", metavar="HOST[:PORT]", help="Sets the address the proxy should connect to. " "If not given, the proxy connects to the address " "requested by the user. You probably want to set " "this.") ProfileCLI.make_parser(group) group = parser.add_argument_group("downstream options") group.add_argument("-l", "--listen", dest="listen", metavar="HOST[:PORT]", help="Sets the address the proxy should listen on. " "If not given, the proxy listens on port 25565 on " "all interfaces.") group.add_argument("-o", "--online-mode", dest="online_mode", action="store_true", help="If given, users connecting to the proxy are " "authenticated by the Mojang session servers, " "i.e. the server bit of the proxy is running in " "online-mode.") group.add_argument("-v", "--protocol-version", dest="protocol_version", type=int, help="Sets the protocol version that the proxy " "accepts from connecting users. If not set, the " "proxy will attempt to use whichever the user " "requests.") group = parser.add_argument_group("sniffer options") inner_group = group.add_mutually_exclusive_group() inner_group.add_argument("-p", "--packet", dest="packets", action="append", metavar=("DIRECTION", "NAME"), nargs=2, help="Adds a packet to be sniffed. " "DIRECTION should be one of: " "'up' (client --> server), " "'down' (server -> client).") inner_group.add_argument("-d", "--direction", dest="direction", choices=("up", "down"), help="Only sniff packets heading in a particular " "direction.") group.add_argument("-x", "--print-payload", dest="print_payload", action="store_true", help="Prints a hexdump with attempted ASCII " "interpretation of the payload of sniffed " "packets") group.add_argument("-y", "--dump-payload", dest="dump_payload", metavar="DEST_PATH", help="Dumps the payload of sniffed packets to the " "specified directory") args = parser.parse_args(argv) run(args) reactor.run()
def run(args): factory = PacketSnifferDownstreamFactory() factory.profile = yield ProfileCLI.make_profile(args) factory.online_mode = args.online_mode factory.force_protocol_version = args.protocol_version if args.direction is not None: factory.packet_direction = args.direction + "stream" if args.packets is not None: packets = set() for direction, name in args.packets: assert direction in ('up', 'down') direction += 'stream' packets.add((direction, name)) factory.packet_whitelist = packets factory.print_payload = args.print_payload factory.dump_payload = args.dump_payload if args.listen: listen = split_host_port(args.listen) listen_host = listen[0] listen_port = int(listen[1]) else: listen_host = "" listen_port = 25565 if args.connect: connect = split_host_port(args.connect) factory.connect_host = connect[0] factory.connect_port = int(connect[1]) # Connect! yield factory.listen(listen_host, listen_port)
def main(argv): parser = ProfileCLI.make_parser() parser.add_argument("host") parser.add_argument("port", nargs='?', default=25565, type=int) args = parser.parse_args(argv) run(args) reactor.run()
def main(argv): parser = ProfileCLI.make_parser() parser.add_argument("host") parser.add_argument("-p", "--port", default=25565, type=int) args = parser.parse_args(argv) run(args) reactor.run()
def runargs(args, encrypt_tcp_q, decrypt_tcp_q): """ Creates a Minecraft Client Bot, and connects to the Minecraft proxy. This assumes that the Minecraft Proxy is already running on another machine. """ profile = yield ProfileCLI.make_profile(args) factory = MinecraftEncoderFactory(profile, encrypt_tcp_q, decrypt_tcp_q) factory.connect(args.host, args.port)
def run(args): # Log in profile = yield ProfileCLI.make_profile(args) # Create factory factory = MinecraftFactory(profile) # Connect! factory.connect(args.host, args.port)
def run(args): # Log in profile = yield ProfileCLI.make_profile(args) # Create factory factory = PlayerListFactory(profile) # Connect! factory.connect(args.host, args.port)
def run(args): # Log in profile = yield ProfileCLI.make_profile(args) # Create factory factory = MinecraftFactory(profile) # Connect! yield factory.connect(args.host, args.port)
def run(args): # Log in profile = yield ProfileCLI.make_profile(args) # Create factory factory = DataPackDumperFactory(profile) factory.output_path = args.output_path # Connect! factory.connect(args.host, args.port)
def run(args, xcoor, ycoor, zcoor): # Log in profile = yield ProfileCLI.make_profile(args) # Create factory factory = ChunkFactory(profile) factory.transferCoor(xcoor, ycoor, zcoor) # Connect! factory.connect(args.host, args.port)
def main(argv): parser = ProfileCLI.make_parser() parser.add_argument("host") parser.add_argument("-p", "--port", default=25565, type=int) args = parser.parse_args(argv) xcoor = input("Enter x coordinate: ") ycoor = input("Enter y coordinate: ") zcoor = input("Enter z coordinate: ") run(args, xcoor, ycoor, zcoor) reactor.run()
def client_forward_packet(encrypt_tcp_q, decrypt_tcp_q, forward_addr): """ Starts twisted's event listener for sending and recieving minecraft packets, and sets up the client bot to connect to the proper host machine using the runargs function. Also passes the encrypt_tcp_q (for forwarding encrypted packets) and the decrypt_tcp_q (for receiving encrypted packets) to the minecraft client encoder object. """ parser = ProfileCLI.make_parser() parser.add_argument("host") parser.add_argument("-p", "--port", default=25565, type=int) #Later take input and/or pick from a name in a database myarr = [forward_addr, "--offline-name", "Notch"] args = parser.parse_args(myarr) runargs(args, encrypt_tcp_q, decrypt_tcp_q) reactor.run()