Skip to content

Commit

Permalink
v1.0.1-rc.2; PyPi Reformatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-Becker committed May 13, 2022
1 parent 5a67872 commit ff69363
Show file tree
Hide file tree
Showing 43 changed files with 375 additions and 64 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added dist/heimdall-1.0.0rc1.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion env/conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"version": "v1.0.0-rc.1"
"version": "v1.0.0-rc.2"
},
"defaults": {

Expand Down
10 changes: 10 additions & 0 deletions heimdall.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Metadata-Version: 2.1
Name: heimdall
Version: 1.0.0rc1
Summary: Heimdall is an advanced and modular smart-contract toolkit which aims to make dealing with smart contracts on EVM based chains easier.
Home-page: https://github.com/Jon-Becker/heimdall
Author: Jonathan Becker (jon-becker)
Author-email: [email protected]
License: MIT
Keywords: ethereum,evm,decompiler,evm decompiler,smart contract,smart contract decompiler,evm smart contract decompiler,eth contract decompiler
License-File: LICENSE
10 changes: 10 additions & 0 deletions heimdall.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
LICENSE
README.md
setup.py
heimdall/__main__.py
heimdall.egg-info/PKG-INFO
heimdall.egg-info/SOURCES.txt
heimdall.egg-info/dependency_links.txt
heimdall.egg-info/entry_points.txt
heimdall.egg-info/requires.txt
heimdall.egg-info/top_level.txt
1 change: 1 addition & 0 deletions heimdall.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions heimdall.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[console_scripts]
heimdall = heimdall.__main__:main
8 changes: 8 additions & 0 deletions heimdall.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
requests
web3
numpy
bidict
alive-progress
argparse
argcomplete
eth_abi
1 change: 1 addition & 0 deletions heimdall.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
heimdall
126 changes: 65 additions & 61 deletions heimdall.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,71 +16,75 @@
from lib.utils.logger import log
from lib.utils.version import getLocalVersion, getRemoteVersion

command = 'clear'
if os.name in ('nt', 'dos'):
command = 'cls'
os.system(command)
print(getHeader())
if getLocalVersion() != getRemoteVersion() and getRemoteVersion() != False:
log('alert', f'This version of Heimdall is outdated!')
log('alert', f'Version {colorLib.GREEN}{getRemoteVersion()}{colorLib.RESET} is available at {colorLib.GREEN}https://github.com/Jon-Becker/heimdall/releases/tag/{getRemoteVersion()}{colorLib.RESET}')
def main(argv=None):
command = 'clear'
if os.name in ('nt', 'dos'):
command = 'cls'
os.system(command)
print(getHeader())
if getLocalVersion() != getRemoteVersion() and getRemoteVersion() != False:
log('alert', f'This version of Heimdall is outdated!')
log('alert', f'Version {colorLib.GREEN}{getRemoteVersion()}{colorLib.RESET} is available at {colorLib.GREEN}https://github.com/Jon-Becker/heimdall/releases/tag/{getRemoteVersion()}{colorLib.RESET}')

heimdall = argparse.ArgumentParser(prog='heimdall', usage='heimdall [options]', add_help=False)
heimdall = argparse.ArgumentParser(prog='heimdall', usage='heimdall [options]', add_help=False)

heimdall.add_argument('-m', '--module', help="Operation module")
heimdall.add_argument('-t', '--target', help="Operation target")
heimdall.add_argument('-o', '--output', help="Path to write output to")
heimdall.add_argument('-c', '--chain', help="Chain ID of target network")
heimdall.add_argument('-p', '--provider', help="Custom provider URL")
heimdall.add_argument('--redeploy', help="Redeploy contract")
heimdall.add_argument('-m', '--module', help="Operation module")
heimdall.add_argument('-t', '--target', help="Operation target")
heimdall.add_argument('-o', '--output', help="Path to write output to")
heimdall.add_argument('-c', '--chain', help="Chain ID of target network")
heimdall.add_argument('-p', '--provider', help="Custom provider URL")
heimdall.add_argument('--redeploy', help="Redeploy contract")

heimdall.add_argument('-v', '--verbose', help="Use verbose mode", action="store_true")
heimdall.add_argument('-h', '--help', help="Show the help menu", action="store_true")
heimdall.add_argument('--version', help="Display version information", action="store_true")
heimdall.add_argument('--update', help="Update heimdall to latest release", action="store_true")
heimdall.add_argument('--beautify', help="Beautify contract, using statistical renaming", action="store_true")
heimdall.add_argument('--default', help="Always use defaults when prompted for input", action="store_true")
heimdall.add_argument('--flush', help="Flushes the cache", action="store_true")
heimdall.add_argument('--ignore-cache', help="Ignores the cache (SLOWER!)", action="store_true")
heimdall.add_argument('-v', '--verbose', help="Use verbose mode", action="store_true")
heimdall.add_argument('-h', '--help', help="Show the help menu", action="store_true")
heimdall.add_argument('--version', help="Display version information", action="store_true")
heimdall.add_argument('--update', help="Update heimdall to latest release", action="store_true")
heimdall.add_argument('--beautify', help="Beautify contract, using statistical renaming", action="store_true")
heimdall.add_argument('--default', help="Always use defaults when prompted for input", action="store_true")
heimdall.add_argument('--flush', help="Flushes the cache", action="store_true")
heimdall.add_argument('--ignore-cache', help="Ignores the cache (SLOWER!)", action="store_true")

args = heimdall.parse_args()
try:
if args.help:
print(getHelp())
args = heimdall.parse_args(argv[1:])
try:
if args.help:
print(getHelp())

else:
if args.module:
handled = False
startTime = timer()
else:
if args.module:
handled = False
startTime = timer()

available_modules = getModules(args)
if args.module.lower().isdigit() and (int(args.module) <= len(available_modules[0])-1):
selected_module = importlib.import_module(available_modules[0][int(args.module)]['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')
else:
for module in available_modules[0]:
if args.module.lower() == module["title"].lower():
selected_module = importlib.import_module(module['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')

if not handled:
print(f'heimdall: error: Module {colorLib.YELLOW}{args.module}{colorLib.RESET} not found. Use -h to show the help menu.\n')
available_modules = getModules(args)
if args.module.lower().isdigit() and (int(args.module) <= len(available_modules[0])-1):
selected_module = importlib.import_module(available_modules[0][int(args.module)]['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')
else:
for module in available_modules[0]:
if args.module.lower() == module["title"].lower():
selected_module = importlib.import_module(module['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')
if not handled:
print(f'heimdall: error: Module {colorLib.YELLOW}{args.module}{colorLib.RESET} not found. Use -h to show the help menu.\n')

endTime = timer()
log('info', f'Operation completed in {datetime.timedelta(seconds=(endTime-startTime))}.\n')
else:
print('heimdall: error: Missing a mandatory option (-m or --module). Use -h to show the help menu.\n')
except KeyboardInterrupt:
endTime = timer()
log('critical', f'Operation aborted after {datetime.timedelta(seconds=(endTime-startTime))}.\n')
sys.exit(0)
endTime = timer()
log('info', f'Operation completed in {datetime.timedelta(seconds=(endTime-startTime))}.\n')
else:
print('heimdall: error: Missing a mandatory option (-m or --module). Use -h to show the help menu.\n')
except KeyboardInterrupt:
endTime = timer()
log('critical', f'Operation aborted after {datetime.timedelta(seconds=(endTime-startTime))}.\n')
sys.exit(0)

if __name__ == '__main__':
sys.exit(main(sys.argv))
90 changes: 90 additions & 0 deletions heimdall/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import argparse
import datetime
from inspect import trace
import os
import sys
import importlib
import traceback

from lib.modules.modules import getModules

from timeit import default_timer as timer

from lib.utils.colors import colorLib
from lib.menus.header import getHeader
from lib.menus.help import getHelp
from lib.utils.logger import log
from lib.utils.version import getLocalVersion, getRemoteVersion

def main(argv=None):
command = 'clear'
if os.name in ('nt', 'dos'):
command = 'cls'
os.system(command)
print(getHeader())
if getLocalVersion() != getRemoteVersion() and getRemoteVersion() != False:
log('alert', f'This version of Heimdall is outdated!')
log('alert', f'Version {colorLib.GREEN}{getRemoteVersion()}{colorLib.RESET} is available at {colorLib.GREEN}https://github.com/Jon-Becker/heimdall/releases/tag/{getRemoteVersion()}{colorLib.RESET}')

heimdall = argparse.ArgumentParser(prog='heimdall', usage='heimdall [options]', add_help=False)

heimdall.add_argument('-m', '--module', help="Operation module")
heimdall.add_argument('-t', '--target', help="Operation target")
heimdall.add_argument('-o', '--output', help="Path to write output to")
heimdall.add_argument('-c', '--chain', help="Chain ID of target network")
heimdall.add_argument('-p', '--provider', help="Custom provider URL")
heimdall.add_argument('--redeploy', help="Redeploy contract")

heimdall.add_argument('-v', '--verbose', help="Use verbose mode", action="store_true")
heimdall.add_argument('-h', '--help', help="Show the help menu", action="store_true")
heimdall.add_argument('--version', help="Display version information", action="store_true")
heimdall.add_argument('--update', help="Update heimdall to latest release", action="store_true")
heimdall.add_argument('--beautify', help="Beautify contract, using statistical renaming", action="store_true")
heimdall.add_argument('--default', help="Always use defaults when prompted for input", action="store_true")
heimdall.add_argument('--flush', help="Flushes the cache", action="store_true")
heimdall.add_argument('--ignore-cache', help="Ignores the cache (SLOWER!)", action="store_true")

args = heimdall.parse_args(argv[1:])
try:
if args.help:
print(getHelp())

else:
if args.module:
handled = False
startTime = timer()

available_modules = getModules(args)
if args.module.lower().isdigit() and (int(args.module) <= len(available_modules[0])-1):
selected_module = importlib.import_module(available_modules[0][int(args.module)]['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')
else:
for module in available_modules[0]:
if args.module.lower() == module["title"].lower():
selected_module = importlib.import_module(module['import'])
handled = True
try:
selected_module.main(args)
except Exception as e:
traceback.print_exc()
log('critical', f'Execution failed! Advanced logs available.')

if not handled:
print(f'heimdall: error: Module {colorLib.YELLOW}{args.module}{colorLib.RESET} not found. Use -h to show the help menu.\n')

endTime = timer()
log('info', f'Operation completed in {datetime.timedelta(seconds=(endTime-startTime))}.\n')
else:
print('heimdall: error: Missing a mandatory option (-m or --module). Use -h to show the help menu.\n')
except KeyboardInterrupt:
endTime = timer()
log('critical', f'Operation aborted after {datetime.timedelta(seconds=(endTime-startTime))}.\n')
sys.exit(0)

if __name__ == '__main__':
sys.exit(main(sys.argv))
Binary file added heimdall/lib/.DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/modules/modules.py → heimdall/lib/modules/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def getModules(args=None):
mods = []
max_title_length = 0
max_description_length = 0
for item in os.listdir("./lib/modules"):
for item in os.listdir("./heimdall/lib/modules"):
if item.endswith('.py') and not "modules" in item:
try:
temp = importlib.import_module(f'lib.modules.{item.replace(".py", "")}')
Expand All @@ -28,4 +28,4 @@ def getModules(args=None):
log('warning', f'└─({colorLib.GREY}{e.path}{colorLib.RESET})')
except:
pass
return (mods, max_title_length, max_description_length)
return (mods, max_title_length, max_description_length)
Loading

0 comments on commit ff69363

Please sign in to comment.