acuarica / evm

A Symbolic Ethereum Virtual Machine (EVM) bytecode interpreter, parser and decompiler, along with several other utils for programmatically extracting information from EVM bytecode.
https://acuarica.github.io/evm/
MIT License
62 stars 9 forks source link

should every method hash be included in opcodes? #49

Closed jjordan-quantum closed 1 year ago

jjordan-quantum commented 1 year ago

I have a compiled contract for which I used the decode function found within the opcodes.ts file in this repo.

With the resulting set of opcodes, I have parsed / formatted the pushdata into an array of strings for all 'PUSH4' items.

Within that final set, there seems to be a method hash missing from one of the smart contract functions.

The missing method hash is 0x00879679. The method can still be called though, so its definitely there. And it's state changing, so called in tx.

This method was also missing when decompiling using the repo you forked from by @MrLuit

Here is the code:

0x60806040526004361061016d5760003560e01c8063810c48c3116100cb578063ad5c46481161007f578063c45a015511610059578063c45a015514610a39578063e8e3370014610a4e578063ff0fb72c14610ab0576101a6565b8063ad5c464814610975578063ad615dec146109a6578063baa2abde146109dc576101a6565b80638803dbee116100b05780638803dbee146107bf57806396e5213814610857578063a0bee3f5146108ef576101a6565b8063810c48c31461073657806385f8c25914610789576101a6565b806338ed1739116101225780635a2b5106116101075780635a2b5106146105615780635c11d795146106185780636041ab15146106b0576101a6565b806338ed1739146104315780634d3d2739146104c9576101a6565b8063136e9ee911610153578063136e9ee91461025f5780631703a5d71461033557806318dd2b3514610399576101a6565b8062879679146101ab578063054d50d414610217576101a6565b366101a657336001600160a01b037f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b616146101a457fe5b005b600080fd5b3480156101b757600080fd5b506101fe600480360360c08110156101ce57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a00135610b67565b6040805192835260208301919091528051918290030190f35b34801561022357600080fd5b5061024d6004803603606081101561023a57600080fd5b5080359060208101359060400135610c81565b60408051918252519081900360200190f35b6102e56004803603608081101561027557600080fd5b8135919081019060408101602082013564010000000081111561029757600080fd5b8201836020820111156102a957600080fd5b803590602001918460208302840111640100000000831117156102cb57600080fd5b91935091506001600160a01b038135169060200135610c96565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610321578181015183820152602001610309565b505050509050019250505060405180910390f35b61037b600480360360c081101561034b57600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a0013561102d565b60408051938452602084019290925282820152519081900360600190f35b3480156103a557600080fd5b506101a4600480360360a08110156103bc57600080fd5b8135916020810135918101906060810160408201356401000000008111156103e357600080fd5b8201836020820111156103f557600080fd5b8035906020019184602083028401116401000000008311171561041757600080fd5b91935091506001600160a01b0381351690602001356112d2565b34801561043d57600080fd5b506102e5600480360360a081101561045457600080fd5b81359160208101359181019060608101604082013564010000000081111561047b57600080fd5b82018360208201111561048d57600080fd5b803590602001918460208302840111640100000000831117156104af57600080fd5b91935091506001600160a01b0381351690602001356115ba565b3480156104d557600080fd5b506102e5600480360360a08110156104ec57600080fd5b81359160208101359181019060608101604082013564010000000081111561051357600080fd5b82018360208201111561052557600080fd5b8035906020019184602083028401116401000000008311171561054757600080fd5b91935091506001600160a01b038135169060200135611789565b34801561056d57600080fd5b506102e56004803603604081101561058457600080fd5b813591908101906040810160208201356401000000008111156105a657600080fd5b8201836020820111156105b857600080fd5b803590602001918460208302840111640100000000831117156105da57600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550611a2c945050505050565b34801561062457600080fd5b506101a4600480360360a081101561063b57600080fd5b81359160208101359181019060608101604082013564010000000081111561066257600080fd5b82018360208201111561067457600080fd5b8035906020019184602083028401116401000000008311171561069657600080fd5b91935091506001600160a01b038135169060200135611a62565b6102e5600480360360808110156106c657600080fd5b813591908101906040810160208201356401000000008111156106e857600080fd5b8201836020820111156106fa57600080fd5b8035906020019184602083028401116401000000008311171561071c57600080fd5b91935091506001600160a01b038135169060200135611c88565b34801561074257600080fd5b5061024d600480360360c081101561075957600080fd5b506001600160a01b0381358116916020810135916040820135916060810135916080820135169060a0013561201c565b34801561079557600080fd5b5061024d600480360360608110156107ac57600080fd5b508035906020810135906040013561219d565b3480156107cb57600080fd5b506102e5600480360360a08110156107e257600080fd5b81359160208101359181019060608101604082013564010000000081111561080957600080fd5b82018360208201111561081b57600080fd5b8035906020019184602083028401116401000000008311171561083d57600080fd5b91935091506001600160a01b0381351690602001356121aa565b34801561086357600080fd5b506102e5600480360360a081101561087a57600080fd5b8135916020810135918101906060810160408201356401000000008111156108a157600080fd5b8201836020820111156108b357600080fd5b803590602001918460208302840111640100000000831117156108d557600080fd5b91935091506001600160a01b0381351690602001356122a3565b6101a46004803603608081101561090557600080fd5b8135919081019060408101602082013564010000000081111561092757600080fd5b82018360208201111561093957600080fd5b8035906020019184602083028401116401000000008311171561095b57600080fd5b91935091506001600160a01b038135169060200135612444565b34801561098157600080fd5b5061098a6127e2565b604080516001600160a01b039092168252519081900360200190f35b3480156109b257600080fd5b5061024d600480360360608110156109c957600080fd5b5080359060208101359060400135612806565b3480156109e857600080fd5b506101fe600480360360e08110156109ff57600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359091169060c00135612813565b348015610a4557600080fd5b5061098a612a70565b348015610a5a57600080fd5b5061037b6004803603610100811015610a7257600080fd5b506001600160a01b038135811691602081013582169160408201359160608101359160808201359160a08101359160c0820135169060e00135612a94565b348015610abc57600080fd5b506102e560048036036040811015610ad357600080fd5b81359190810190604081016020820135640100000000811115610af557600080fd5b820183602082011115610b0757600080fd5b80359060200191846020830284011164010000000083111715610b2957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612bd0945050505050565b6000808242811015610bae576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b610bdd897f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b68a8a8a308a612813565b9093509150610bed898685612bfd565b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b158015610c5357600080fd5b505af1158015610c67573d6000803e3d6000fd5b50505050610c758583612d95565b50965096945050505050565b6000610c8e848484612e8d565b949350505050565b60608142811015610cdc576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031686866000818110610d1357fe5b905060200201356001600160a01b03166001600160a01b031614610d7e576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b610ddc7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a34888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612f7d92505050565b91508682600184510381518110610def57fe5b60200260200101511015610e345760405162461bcd60e51b815260040180806020018281038252602b8152602001806141fb602b913960400191505060405180910390fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663d0e30db083600081518110610e7057fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015610ea357600080fd5b505af1158015610eb7573d6000803e3d6000fd5b50505050507f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663a9059cbb610f4e7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89896000818110610f1c57fe5b905060200201356001600160a01b03168a8a6001818110610f3957fe5b905060200201356001600160a01b03166130c9565b84600081518110610f5b57fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015610fb257600080fd5b505af1158015610fc6573d6000803e3d6000fd5b505050506040513d6020811015610fdc57600080fd5b5051610fe457fe5b611023828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506131a1915050565b5095945050505050565b60008060008342811015611076576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b6110a48a7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b68b348c8c6133e7565b909450925060006110f67f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8c7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66130c9565b90506111048b33838861368d565b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b15801561115f57600080fd5b505af1158015611173573d6000803e3d6000fd5b50505050507f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663a9059cbb82866040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b1580156111f857600080fd5b505af115801561120c573d6000803e3d6000fd5b505050506040513d602081101561122257600080fd5b505161122a57fe5b806001600160a01b0316636a627842886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b15801561128257600080fd5b505af1158015611296573d6000803e3d6000fd5b505050506040513d60208110156112ac57600080fd5b50519250348410156112c4576112c433853403612d95565b505096509650969350505050565b8042811015611316576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b6168585600019810181811061135057fe5b905060200201356001600160a01b03166001600160a01b0316146113bb576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b611413858560008181106113cb57fe5b905060200201356001600160a01b03163361140d7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89896000818110610f1c57fe5b8a61368d565b6114518585808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506137ff915050565b604080516370a0823160e01b815230600482015290516000916001600160a01b037f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b616916370a0823191602480820192602092909190829003018186803b1580156114bb57600080fd5b505afa1580156114cf573d6000803e3d6000fd5b505050506040513d60208110156114e557600080fd5b50519050868110156115285760405162461bcd60e51b815260040180806020018281038252602b8152602001806141fb602b913960400191505060405180910390fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b0316632e1a7d4d826040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561158e57600080fd5b505af11580156115a2573d6000803e3d6000fd5b505050506115b08482612d95565b5050505050505050565b60608142811015611600576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b61165e7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612f7d92505050565b9150868260018451038151811061167157fe5b602002602001015110156116b65760405162461bcd60e51b815260040180806020018281038252602b8152602001806141fb602b913960400191505060405180910390fd5b61173f868660008181106116c657fe5b905060200201356001600160a01b0316336117257f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8a8a600081811061170857fe5b905060200201356001600160a01b03168b8b6001818110610f3957fe5b8560008151811061173257fe5b602002602001015161368d565b61177e828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506131a1915050565b509695505050505050565b606081428110156117cf576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b6168686600019810181811061180957fe5b905060200201356001600160a01b03166001600160a01b031614611874576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b6118d27f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250613b2a92505050565b915086826000815181106118e257fe5b602002602001015111156119275760405162461bcd60e51b815260040180806020018281038252602781526020018061418b6027913960400191505060405180910390fd5b611937868660008181106116c657fe5b611976828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152503092506131a1915050565b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b0316632e1a7d4d836001855103815181106119b557fe5b60200260200101516040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156119f357600080fd5b505af1158015611a07573d6000803e3d6000fd5b5050505061177e8483600185510381518110611a1f57fe5b6020026020010151612d95565b6060611a597f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8484613b2a565b90505b92915050565b8042811015611aa6576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b611ab6858560008181106113cb57fe5b600085856000198101818110611ac857fe5b905060200201356001600160a01b03166001600160a01b03166370a08231856040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611b2d57600080fd5b505afa158015611b41573d6000803e3d6000fd5b505050506040513d6020811015611b5757600080fd5b50516040805160208881028281018201909352888252929350611b999290918991899182918501908490808284376000920191909152508892506137ff915050565b86611c4b8288886000198101818110611bae57fe5b905060200201356001600160a01b03166001600160a01b03166370a08231886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611c1357600080fd5b505afa158015611c27573d6000803e3d6000fd5b505050506040513d6020811015611c3d57600080fd5b50519063ffffffff613c6216565b10156115b05760405162461bcd60e51b815260040180806020018281038252602b8152602001806141fb602b913960400191505060405180910390fd5b60608142811015611cce576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031686866000818110611d0557fe5b905060200201356001600160a01b03166001600160a01b031614611d70576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b611dce7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a88888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250613b2a92505050565b91503482600081518110611dde57fe5b60200260200101511115611e235760405162461bcd60e51b815260040180806020018281038252602781526020018061418b6027913960400191505060405180910390fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663d0e30db083600081518110611e5f57fe5b60200260200101516040518263ffffffff1660e01b81526004016000604051808303818588803b158015611e9257600080fd5b505af1158015611ea6573d6000803e3d6000fd5b50505050507f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663a9059cbb611f0b7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89896000818110610f1c57fe5b84600081518110611f1857fe5b60200260200101516040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b158015611f6f57600080fd5b505af1158015611f83573d6000803e3d6000fd5b505050506040513d6020811015611f9957600080fd5b5051611fa157fe5b611fe0828787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508992506131a1915050565b81600081518110611fed57fe5b602002602001015134111561102357611023338360008151811061200d57fe5b60200260200101513403612d95565b60008142811015612062576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b612091887f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b68989893089612813565b604080516370a0823160e01b8152306004820152905191945061211592508a9187916001600160a01b038416916370a0823191602480820192602092909190829003018186803b1580156120e457600080fd5b505afa1580156120f8573d6000803e3d6000fd5b505050506040513d602081101561210e57600080fd5b5051612bfd565b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b0316632e1a7d4d836040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b15801561217b57600080fd5b505af115801561218f573d6000803e3d6000fd5b5050505061177e8483612d95565b6000610c8e848484613cba565b606081428110156121f0576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b61224e7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250613b2a92505050565b9150868260008151811061225e57fe5b602002602001015111156116b65760405162461bcd60e51b815260040180806020018281038252602781526020018061418b6027913960400191505060405180910390fd5b606081428110156122e9576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b6001600160a01b037f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b6168686600019810181811061232357fe5b905060200201356001600160a01b03166001600160a01b03161461238e576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b6123ec7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89888880806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250612f7d92505050565b915086826001845103815181106123ff57fe5b602002602001015110156119275760405162461bcd60e51b815260040180806020018281038252602b8152602001806141fb602b913960400191505060405180910390fd5b8042811015612488576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b0316858560008181106124bf57fe5b905060200201356001600160a01b03166001600160a01b03161461252a576040805162461bcd60e51b815260206004820152601d60248201527f556e69737761705632526f757465723a20494e56414c49445f50415448000000604482015290519081900360640190fd5b60003490507f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663d0e30db0826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561258a57600080fd5b505af115801561259e573d6000803e3d6000fd5b50505050507f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b66001600160a01b031663a9059cbb6126037f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a89896000818110610f1c57fe5b836040518363ffffffff1660e01b815260040180836001600160a01b03166001600160a01b0316815260200182815260200192505050602060405180830381600087803b15801561265357600080fd5b505af1158015612667573d6000803e3d6000fd5b505050506040513d602081101561267d57600080fd5b505161268557fe5b60008686600019810181811061269757fe5b905060200201356001600160a01b03166001600160a01b03166370a08231866040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b1580156126fc57600080fd5b505afa158015612710573d6000803e3d6000fd5b505050506040513d602081101561272657600080fd5b505160408051602089810282810182019093528982529293506127689290918a918a9182918501908490808284376000920191909152508992506137ff915050565b87611c4b828989600019810181811061277d57fe5b905060200201356001600160a01b03166001600160a01b03166370a08231896040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611c1357600080fd5b7f000000000000000000000000e0b148dd4835e8beb65762c5094f4805e48130b681565b6000610c8e848484613daa565b600080824281101561285a576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b60006128877f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8c8c6130c9565b604080516323b872dd60e01b81523360048201526001600160a01b03831660248201819052604482018d9052915192935090916323b872dd916064808201926020929091908290030181600087803b1580156128e257600080fd5b505af11580156128f6573d6000803e3d6000fd5b505050506040513d602081101561290c57600080fd5b5050604080517f89afcb440000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015282516000938493928616926389afcb44926024808301939282900301818787803b15801561297257600080fd5b505af1158015612986573d6000803e3d6000fd5b505050506040513d604081101561299c57600080fd5b508051602090910151909250905060006129b68e8e613e56565b509050806001600160a01b03168e6001600160a01b0316146129d95781836129dc565b82825b90975095508a871015612a205760405162461bcd60e51b81526004018080602001828103825260268152602001806141b26026913960400191505060405180910390fd5b89861015612a5f5760405162461bcd60e51b81526004018080602001828103825260268152602001806141186026913960400191505060405180910390fd5b505050505097509795505050505050565b7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a81565b60008060008342811015612add576040805162461bcd60e51b81526020600482015260186024820152600080516020614275833981519152604482015290519081900360640190fd5b612aeb8c8c8c8c8c8c6133e7565b90945092506000612b1d7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8e8e6130c9565b9050612b2b8d33838861368d565b612b378c33838761368d565b806001600160a01b0316636a627842886040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b03168152602001915050602060405180830381600087803b158015612b8f57600080fd5b505af1158015612ba3573d6000803e3d6000fd5b505050506040513d6020811015612bb957600080fd5b5051949d939c50939a509198505050505050505050565b6060611a597f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8484612f7d565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000178152925182516000946060949389169392918291908083835b60208310612ca85780518252601f199092019160209182019101612c89565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612d0a576040519150601f19603f3d011682016040523d82523d6000602084013e612d0f565b606091505b5091509150818015612d3d575080511580612d3d5750808060200190516020811015612d3a57600080fd5b50515b612d8e576040805162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c454400604482015290519081900360640190fd5b5050505050565b604080516000808252602082019092526001600160a01b0384169083906040518082805190602001908083835b60208310612de15780518252601f199092019160209182019101612dc2565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612e43576040519150601f19603f3d011682016040523d82523d6000602084013e612e48565b606091505b5050905080612e885760405162461bcd60e51b81526004018080602001828103825260238152602001806141d86023913960400191505060405180910390fd5b505050565b6000808411612ecd5760405162461bcd60e51b815260040180806020018281038252602b81526020018061424a602b913960400191505060405180910390fd5b600083118015612edd5750600082115b612f185760405162461bcd60e51b815260040180806020018281038252602881526020018061413e6028913960400191505060405180910390fd5b6000612f2c856103e563ffffffff613f3416565b90506000612f40828563ffffffff613f3416565b90506000612f6683612f5a886103e863ffffffff613f3416565b9063ffffffff613fa016565b9050808281612f7157fe5b04979650505050505050565b6060600282511015612fd6576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f504154480000604482015290519081900360640190fd5b815167ffffffffffffffff81118015612fee57600080fd5b50604051908082528060200260200182016040528015613018578160200160208202803683370190505b509050828160008151811061302957fe5b60200260200101818152505060005b60018351038110156130c15760008061307b8786858151811061305757fe5b602002602001015187866001018151811061306e57fe5b6020026020010151613ff8565b9150915061309d84848151811061308e57fe5b60200260200101518383612e8d565b8484600101815181106130ac57fe5b60209081029190910101525050600101613038565b509392505050565b60008060006130d88585613e56565b604080516bffffffffffffffffffffffff19606094851b811660208084019190915293851b81166034830152825160288184030181526048830184528051908501207fff0000000000000000000000000000000000000000000000000000000000000060688401529a90941b9093166069840152607d8301989098527fb19e8e1fdf9825830e275dcb18cc9c31fe76f313a5ae3aef7501b31f4958daa1609d808401919091528851808403909101815260bd909201909752805196019590952095945050505050565b60005b60018351038110156133e1576000808483815181106131bf57fe5b60200260200101518584600101815181106131d657fe5b60200260200101519150915060006131ee8383613e56565b509050600087856001018151811061320257fe5b60200260200101519050600080836001600160a01b0316866001600160a01b03161461323057826000613234565b6000835b91509150600060028a5103881061324b578861328c565b61328c7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a878c8b6002018151811061327f57fe5b60200260200101516130c9565b90506132b97f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a88886130c9565b6001600160a01b031663022c0d9f84848460006040519080825280601f01601f1916602001820160405280156132f6576020820181803683370190505b506040518563ffffffff1660e01b815260040180858152602001848152602001836001600160a01b03166001600160a01b0316815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561336757818101518382015260200161334f565b50505050905090810190601f1680156133945780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b1580156133b657600080fd5b505af11580156133ca573d6000803e3d6000fd5b5050600190990198506131a4975050505050505050565b50505050565b604080517fe6a439050000000000000000000000000000000000000000000000000000000081526001600160a01b03888116600483015287811660248301529151600092839283927f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a9092169163e6a4390591604480820192602092909190829003018186803b15801561347a57600080fd5b505afa15801561348e573d6000803e3d6000fd5b505050506040513d60208110156134a457600080fd5b50516001600160a01b0316141561357057604080517fc9c653960000000000000000000000000000000000000000000000000000000081526001600160a01b038a81166004830152898116602483015291517f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a9092169163c9c65396916044808201926020929091908290030181600087803b15801561354357600080fd5b505af1158015613557573d6000803e3d6000fd5b505050506040513d602081101561356d57600080fd5b50505b60008061359e7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a8b8b613ff8565b915091508160001480156135b0575080155b156135c057879350869250613680565b60006135cd898484613daa565b905087811161362057858110156136155760405162461bcd60e51b81526004018080602001828103825260268152602001806141186026913960400191505060405180910390fd5b88945092508261367e565b600061362d898486613daa565b90508981111561363957fe5b878110156136785760405162461bcd60e51b81526004018080602001828103825260268152602001806141b26026913960400191505060405180910390fd5b94508793505b505b5050965096945050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166323b872dd60e01b17815292518251600094606094938a169392918291908083835b602083106137275780518252601f199092019160209182019101613708565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613789576040519150601f19603f3d011682016040523d82523d6000602084013e61378e565b606091505b50915091508180156137bc5750805115806137bc57508080602001905160208110156137b957600080fd5b50515b6137f75760405162461bcd60e51b81526004018080602001828103825260248152602001806142266024913960400191505060405180910390fd5b505050505050565b60005b6001835103811015612e885760008084838151811061381d57fe5b602002602001015185846001018151811061383457fe5b602002602001015191509150600061384c8383613e56565b509050600061387c7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a85856130c9565b9050600080600080846001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b1580156138bd57600080fd5b505afa1580156138d1573d6000803e3d6000fd5b505050506040513d60608110156138e757600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690506000806001600160a01b038a811690891614613924578284613927565b83835b91509150613985828b6001600160a01b03166370a082318a6040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015611c1357600080fd5b9550613992868383612e8d565b945050505050600080856001600160a01b0316886001600160a01b0316146139bc578260006139c0565b6000835b91509150600060028c51038a106139d7578a613a0b565b613a0b7f00000000000000000000000046d8db3be9990d546a255da307a02556b02d397a898e8d6002018151811061327f57fe5b60408051600080825260208201928390527f022c0d9f00000000000000000000000000000000000000000000000000000000835260248201878152604483018790526001600160a01b038086166064850152608060848501908152845160a48601819052969750908c169563022c0d9f958a958a958a9591949193919260c486019290918190849084905b83811015613aae578181015183820152602001613a96565b50505050905090810190601f168015613adb5780820380516001836020036101000a031916815260200191505b5095505050505050600060405180830381600087803b158015613afd57600080fd5b505af1158015613b11573d6000803e3d6000fd5b50506001909b019a506138029950505050505050505050565b6060600282511015613b83576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a20494e56414c49445f504154480000604482015290519081900360640190fd5b815167ffffffffffffffff81118015613b9b57600080fd5b50604051908082528060200260200182016040528015613bc5578160200160208202803683370190505b5090508281600183510381518110613bd957fe5b60209081029190910101528151600019015b80156130c157600080613c1b87866001860381518110613c0757fe5b602002602001015187868151811061306e57fe5b91509150613c3d848481518110613c2e57fe5b60200260200101518383613cba565b846001850381518110613c4c57fe5b6020908102919091010152505060001901613beb565b80820382811115611a5c576040805162461bcd60e51b815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6000808411613cfa5760405162461bcd60e51b815260040180806020018281038252602c8152602001806140c7602c913960400191505060405180910390fd5b600083118015613d0a5750600082115b613d455760405162461bcd60e51b815260040180806020018281038252602881526020018061413e6028913960400191505060405180910390fd5b6000613d696103e8613d5d868863ffffffff613f3416565b9063ffffffff613f3416565b90506000613d836103e5613d5d868963ffffffff613c6216565b9050613da06001828481613d9357fe5b049063ffffffff613fa016565b9695505050505050565b6000808411613dea5760405162461bcd60e51b81526004018080602001828103825260258152602001806141666025913960400191505060405180910390fd5b600083118015613dfa5750600082115b613e355760405162461bcd60e51b815260040180806020018281038252602881526020018061413e6028913960400191505060405180910390fd5b82613e46858463ffffffff613f3416565b81613e4d57fe5b04949350505050565b600080826001600160a01b0316846001600160a01b03161415613eaa5760405162461bcd60e51b81526004018080602001828103825260258152602001806140f36025913960400191505060405180910390fd5b826001600160a01b0316846001600160a01b031610613eca578284613ecd565b83835b90925090506001600160a01b038216613f2d576040805162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f414444524553530000604482015290519081900360640190fd5b9250929050565b6000811580613f4f57505080820282828281613f4c57fe5b04145b611a5c576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820182811015611a5c576040805162461bcd60e51b815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b60008060006140078585613e56565b5090506000806140188888886130c9565b6001600160a01b0316630902f1ac6040518163ffffffff1660e01b815260040160606040518083038186803b15801561405057600080fd5b505afa158015614064573d6000803e3d6000fd5b505050506040513d606081101561407a57600080fd5b5080516020909101516dffffffffffffffffffffffffffff91821693501690506001600160a01b03878116908416146140b45780826140b7565b81815b9099909850965050505050505056fe556e697377617056324c6962726172793a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056324c6962726172793a204944454e544943414c5f414444524553534553556e69737761705632526f757465723a20494e53554646494349454e545f425f414d4f554e54556e697377617056324c6962726172793a20494e53554646494349454e545f4c4951554944495459556e697377617056324c6962726172793a20494e53554646494349454e545f414d4f554e54556e69737761705632526f757465723a204558434553534956455f494e5055545f414d4f554e54556e69737761705632526f757465723a20494e53554646494349454e545f415f414d4f554e545472616e7366657248656c7065723a204554485f5452414e534645525f4641494c4544556e69737761705632526f757465723a20494e53554646494349454e545f4f55545055545f414d4f554e545472616e7366657248656c7065723a205452414e534645525f46524f4d5f4641494c4544556e697377617056324c6962726172793a20494e53554646494349454e545f494e5055545f414d4f554e54556e69737761705632526f757465723a20455850495245440000000000000000a264697066735822122000d0d4193ba76f0e3efa0a3a883ad995a32e0120cb20b9908db7408e2e25940f64736f6c63430006060033
jjordan-quantum commented 1 year ago

When searching the bytecode for the the set of encoded method signatures (encoded form the contract's ABI), I get the following results:

found: 0xad5c4648
found: 0xe8e33700
found: 0x1703a5d7
found: 0xc45a0155
found: 0x5a2b5106
found: 0xff0fb72c
found: 0x85f8c259
found: 0x054d50d4
found: 0xad615dec
found: 0xbaa2abde
not found: 0x00879679
found: 0x810c48c3
found: 0x6041ab15
found: 0x136e9ee9
found: 0xa0bee3f5
found: 0x96e52138
found: 0x18dd2b35
found: 0x38ed1739
found: 0x5c11d795
found: 0x4d3d2739
found: 0x8803dbee

There's definitely something going on here that I don't understand. Maybe something to do with optimization?

jjordan-quantum commented 1 year ago

Ok...the issue is that the hashed function selector turns out to have 2 leading 0's, therefore it is stored in a JUMP3 opcode, not a JUMP4. Cheers

acuarica commented 8 months ago

Hi @jjordan-quantum, thanks for sending this. You're right, in this case the selector is being pushed with PUSH3 opcode. You can confirm this by running the new sevm CLI tool included in the repo.

In the following, issue.bytecode contains the bytecode posted in the original issue.

$ sevm dis issue.bytecode | grep 879679
  341  PUSH3   0x879679

However, when running the symbolic analysis, this value is correctly detected as a function selector. Try

$ sevm selectors issue.bytecode
0xc45a0155 factory()
0xe8e33700 <no signature>
0xff0fb72c <no signature>
0xad5c4648 WETH()
0xad615dec <no signature>
0xbaa2abde <no signature>
0x8803dbee <no signature>
0x96e52138 <no signature>
0xa0bee3f5 <no signature>
0x810c48c3 <no signature>
0x85f8c259 <no signature>
0x5a2b5106 <no signature>
0x5c11d795 <no signature>
0x6041ab15 <no signature>
0x38ed1739 <no signature>
0x4d3d2739 <no signature>
0x136e9ee9 <no signature>
0x1703a5d7 <no signature>
0x18dd2b35 <no signature>
0x00879679 <no signature>
0x054d50d4 <no signature>

Moreover, you can see where this data flows by running

$ sevm dis issue.bytecode --with-stack | grep 00879679
  345  EQ   〒 eq(msg.sig, 00879679)|local0
  346  PUSH2   0x01ab 〒 [J]0x1ab|eq(msg.sig, 00879679)|local0

meaning that 0x01ab is the program counter for this function's selector.

jjordan-quantum commented 8 months ago

Yeah I guess the issue was with the repo you forked from - when I was originally using the getFunctions() method, it was missing the functions being pushed with a PUSH3, as you can see here - it only filters for PUSH4. At the time, I was blindly trusting the conditions of this filter as a way to identity all contract functions in the code. Tis clear now.