Skip to content

Instantly share code, notes, and snippets.

@juanriaza
Created January 3, 2013 18:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juanriaza/4445496 to your computer and use it in GitHub Desktop.
Save juanriaza/4445496 to your computer and use it in GitHub Desktop.
simpsons tapped out hack
message Currency {
required uint64 a = 1;
required uint64 b = 2;
required uint64 c = 3;
required uint64 donuts = 4;
required uint64 e = 5;
}
# Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='currency.proto',
package='',
serialized_pb='\n\x0e\x63urrency.proto\"F\n\x08\x43urrency\x12\t\n\x01\x61\x18\x01 \x02(\x04\x12\t\n\x01\x62\x18\x02 \x02(\x04\x12\t\n\x01\x63\x18\x03 \x02(\x04\x12\x0e\n\x06\x64onuts\x18\x04 \x02(\x04\x12\t\n\x01\x65\x18\x05 \x02(\x04')
_CURRENCY = descriptor.Descriptor(
name='Currency',
full_name='Currency',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='a', full_name='Currency.a', index=0,
number=1, type=4, cpp_type=4, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='b', full_name='Currency.b', index=1,
number=2, type=4, cpp_type=4, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='c', full_name='Currency.c', index=2,
number=3, type=4, cpp_type=4, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='donuts', full_name='Currency.donuts', index=3,
number=4, type=4, cpp_type=4, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='e', full_name='Currency.e', index=4,
number=5, type=4, cpp_type=4, label=2,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=18,
serialized_end=88,
)
DESCRIPTOR.message_types_by_name['Currency'] = _CURRENCY
class Currency(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _CURRENCY
# @@protoc_insertion_point(class_scope:Currency)
# @@protoc_insertion_point(module_scope)
#!/usr/bin/env python
import os
from libmproxy import proxy, flow
class MyMaster(flow.FlowMaster):
def run(self):
try:
flow.FlowMaster.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, r):
f = flow.FlowMaster.handle_request(self, r)
if f:
r._ack()
return f
def handle_response(self, r):
f = flow.FlowMaster.handle_response(self, r)
if 'protocurrency' in r.request.get_url():
print 'GOT IT'
import currency_pb2
currency = currency_pb2.Currency()
currency.ParseFromString(r.content)
print currency
currency.donuts = long(10000)
print currency
data = currency.SerializeToString()
r.content = data
if f:
r._ack()
print f
return f
config = proxy.ProxyConfig(
cacert = os.path.expanduser("~/.mitmproxy/mitmproxy-ca.pem")
)
state = flow.State()
server = proxy.ProxyServer(config, 8080)
m = MyMaster(server, state)
m.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment