Skip to content

Instantly share code, notes, and snippets.

@zewt
Created December 6, 2017 02:14
Show Gist options
  • Save zewt/5323bbf8f46ef161b20601c75052948a to your computer and use it in GitHub Desktop.
Save zewt/5323bbf8f46ef161b20601c75052948a to your computer and use it in GitHub Desktop.
Python script to give 10000 Eden tokens in Binding of Isaac
# This gives 10000 Eden tokens.
import struct
CrcTable = [ 0x00000000L, 0x09073096L, 0x120E612CL, 0x1B0951BAL, 0xFF6DC419L, 0xF66AF48FL, 0xED63A535L, 0xE46495A3L, 0xFEDB8832L, 0xF7DCB8A4L, 0xECD5E91EL, 0xE5D2D988L, 0x01B64C2BL, 0x08B17CBDL, 0x13B82D07L, 0x1ABF1D91L, 0xFDB71064L, 0xF4B020F2L, 0xEFB97148L, 0xE6BE41DEL, 0x02DAD47DL, 0x0BDDE4EBL, 0x10D4B551L, 0x19D385C7L, 0x036C9856L, 0x0A6BA8C0L, 0x1162F97AL, 0x1865C9ECL, 0xFC015C4FL, 0xF5066CD9L, 0xEE0F3D63L, 0xE7080DF5L, 0xFB6E20C8L, 0xF269105EL, 0xE96041E4L, 0xE0677172L, 0x0403E4D1L, 0x0D04D447L, 0x160D85FDL, 0x1F0AB56BL, 0x05B5A8FAL, 0x0CB2986CL, 0x17BBC9D6L, 0x1EBCF940L, 0xFAD86CE3L, 0xF3DF5C75L, 0xE8D60DCFL, 0xE1D13D59L, 0x06D930ACL, 0x0FDE003AL, 0x14D75180L, 0x1DD06116L, 0xF9B4F4B5L, 0xF0B3C423L, 0xEBBA9599L, 0xE2BDA50FL, 0xF802B89EL, 0xF1058808L, 0xEA0CD9B2L, 0xE30BE924L, 0x076F7C87L, 0x0E684C11L, 0x15611DABL, 0x1C662D3DL, 0xF6DC4190L, 0xFFDB7106L, 0xE4D220BCL, 0xEDD5102AL, 0x09B18589L, 0x00B6B51FL, 0x1BBFE4A5L, 0x12B8D433L, 0x0807C9A2L, 0x0100F934L, 0x1A09A88EL, 0x130E9818L, 0xF76A0DBBL, 0xFE6D3D2DL, 0xE5646C97L, 0xEC635C01L, 0x0B6B51F4L, 0x026C6162L, 0x196530D8L, 0x1062004EL, 0xF40695EDL, 0xFD01A57BL, 0xE608F4C1L, 0xEF0FC457L, 0xF5B0D9C6L, 0xFCB7E950L, 0xE7BEB8EAL, 0xEEB9887CL, 0x0ADD1DDFL, 0x03DA2D49L, 0x18D37CF3L, 0x11D44C65L, 0x0DB26158L, 0x04B551CEL, 0x1FBC0074L, 0x16BB30E2L, 0xF2DFA541L, 0xFBD895D7L, 0xE0D1C46DL, 0xE9D6F4FBL, 0xF369E96AL, 0xFA6ED9FCL, 0xE1678846L, 0xE860B8D0L, 0x0C042D73L, 0x05031DE5L, 0x1E0A4C5FL, 0x170D7CC9L, 0xF005713CL, 0xF90241AAL, 0xE20B1010L, 0xEB0C2086L, 0x0F68B525L, 0x066F85B3L, 0x1D66D409L, 0x1461E49FL, 0x0EDEF90EL, 0x07D9C998L, 0x1CD09822L, 0x15D7A8B4L, 0xF1B33D17L, 0xF8B40D81L, 0xE3BD5C3BL, 0xEABA6CADL, 0xEDB88320L, 0xE4BFB3B6L, 0xFFB6E20CL, 0xF6B1D29AL, 0x12D54739L, 0x1BD277AFL, 0x00DB2615L, 0x09DC1683L, 0x13630B12L, 0x1A643B84L, 0x016D6A3EL, 0x086A5AA8L, 0xEC0ECF0BL, 0xE509FF9DL, 0xFE00AE27L, 0xF7079EB1L, 0x100F9344L, 0x1908A3D2L, 0x0201F268L, 0x0B06C2FEL, 0xEF62575DL, 0xE66567CBL, 0xFD6C3671L, 0xF46B06E7L, 0xEED41B76L, 0xE7D32BE0L, 0xFCDA7A5AL, 0xF5DD4ACCL, 0x11B9DF6FL, 0x18BEEFF9L, 0x03B7BE43L, 0x0AB08ED5L, 0x16D6A3E8L, 0x1FD1937EL, 0x04D8C2C4L, 0x0DDFF252L, 0xE9BB67F1L, 0xE0BC5767L, 0xFBB506DDL, 0xF2B2364BL, 0xE80D2BDAL, 0xE10A1B4CL, 0xFA034AF6L, 0xF3047A60L, 0x1760EFC3L, 0x1E67DF55L, 0x056E8EEFL, 0x0C69BE79L, 0xEB61B38CL, 0xE266831AL, 0xF96FD2A0L, 0xF068E236L, 0x140C7795L, 0x1D0B4703L, 0x060216B9L, 0x0F05262FL, 0x15BA3BBEL, 0x1CBD0B28L, 0x07B45A92L, 0x0EB36A04L, 0xEAD7FFA7L, 0xE3D0CF31L, 0xF8D99E8BL, 0xF1DEAE1DL, 0x1B64C2B0L, 0x1263F226L, 0x096AA39CL, 0x006D930AL, 0xE40906A9L, 0xED0E363FL, 0xF6076785L, 0xFF005713L, 0xE5BF4A82L, 0xECB87A14L, 0xF7B12BAEL, 0xFEB61B38L, 0x1AD28E9BL, 0x13D5BE0DL, 0x08DCEFB7L, 0x01DBDF21L, 0xE6D3D2D4L, 0xEFD4E242L, 0xF4DDB3F8L, 0xFDDA836EL, 0x19BE16CDL, 0x10B9265BL, 0x0BB077E1L, 0x02B74777L, 0x18085AE6L, 0x110F6A70L, 0x0A063BCAL, 0x03010B5CL, 0xE7659EFFL, 0xEE62AE69L, 0xF56BFFD3L, 0xFC6CCF45L, 0xE00AE278L, 0xE90DD2EEL, 0xF2048354L, 0xFB03B3C2L, 0x1F672661L, 0x166016F7L, 0x0D69474DL, 0x046E77DBL, 0x1ED16A4AL, 0x17D65ADCL, 0x0CDF0B66L, 0x05D83BF0L, 0xE1BCAE53L, 0xE8BB9EC5L, 0xF3B2CF7FL, 0xFAB5FFE9L, 0x1DBDF21CL, 0x14BAC28AL, 0x0FB39330L, 0x06B4A3A6L, 0xE2D03605L, 0xEBD70693L, 0xF0DE5729L, 0xF9D967BFL, 0xE3667A2EL, 0xEA614AB8L, 0xF1681B02L, 0xF86F2B94L, 0x1C0BBE37L, 0x150C8EA1L, 0x0E05DF1BL, 0x0702EF8DL ]
def Crc32(data):
start = 0xfedcba76L
crc = (~start) & 0xFFFFFFFF
for c in data:
value = CrcTable[ord(c) ^ (crc & 0xFF)]
crc = (crc >> 8) & 0xFFFFFFFF
crc ^= value
return (~crc) & 0xFFFFFFFF
def go():
filename = 'abp_persistentgamedata2.dat'
f = open(filename)
data = f.read()
# Check the checksum. If this doesn't match, the file format may have changed.
old_crc32 = struct.unpack('I', data[-4:])[0]
hashed_data = data[16:-4]
expected_crc32 = Crc32(data[16:-4])
if old_crc32 != expected_crc32:
print 'Invalid CRC32?'
return
# Set lots of Eden tokens.
data = data[0:0x01DD] + struct.pack('I', 10000) + data[0x01E1:]
# Update the CRC32.
new_crc32 = Crc32(data[16:-4])
new_data = data[:-4] + struct.pack('I', new_crc32)
open(filename, 'w+').write(new_data)
go()
@jojolono
Copy link

hey, man i have a problem, when i put this visual studio code it gives me some errors, why does that happen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment