Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
jorhelp committed Aug 12, 2022
1 parent 43c98b0 commit b469b84
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 124 deletions.
20 changes: 20 additions & 0 deletions Ingram/utils/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""global configure arguments"""
import collections


class Config:
def __init__(self):
self.config_dict = collections.defaultdict(lambda: None)

def set_val(self, key, val):
self.config_dict[key] = val

def get_val(self, key):
return self.config_dict[key]

def __getitem__(self, key):
return self.config_dict[key]


global config
config = Config()
17 changes: 9 additions & 8 deletions Ingram/utils/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
logger.remove(handler_id=None) # do not print to terminal

def no_debug(record):
"""if debug is False, then filter error msg"""
return record['level'].name != 'ERROR'

_formatter = "[{time:YYYY-MM-DD HH:mm:ss}]({level}) From {module}.{function} : {message}"
if debug:
trace = logger.add('test.log', format=_formatter)
else:
trace = logger.add('test.log', format=_formatter, filter=no_debug)
"""if debug is False, then filter error and debug msg"""
return record['level'].name != 'ERROR' and record['level'].name != 'DEBUG'

_formatter = "[{time:YYYY-MM-DD HH:mm:ss}][{level}][{module}.{function}] {message}"
# if debug:
# trace = logger.add('test.log', format=_formatter)
# else:
# trace = logger.add('test.log', format=_formatter, filter=no_debug)
trace = logger.add('test.log', format=_formatter, filter=no_debug)
146 changes: 89 additions & 57 deletions Ingram/utils/logo.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
"""logo"""
import os
import random


logos = [
ingram_icon = r"""
_ __..-:┑
║`=====╩=╩=======╣ |
==#║________███_/ @ ║ |
╚====.===╦==╦=╤==╩#█
\___║::║/
║::║|
║::║_\
██
██
██
██
"""


ingram_fonts = [
r"""
___
|_ _| _ _ __ _ _ _ __ _ _ __
| | | ' \ / _` | | '_| / _` | | ' \
|___| |_||_| \__, | |_| \__,_| |_|_|_|
|___/
""",

r"""
**
**
/** *****
/** ******* **///** ****** ****** **********
/** //**///** /** /** //**//* //////** //**//**//**
Expand All @@ -25,15 +49,6 @@
[..
""",

r"""
## ## ## ###### ##### ###### ## ##
### ## ### ## ## ## ### ## ######
## ###### ## ## ### ## ## #######
## ## ### ## ### ###### ####### ## ##
## ## ## ## ## ## ## ## ## ## ##
##### ## ## ##### ## ### ## ## ## ##
""",

r"""
M""M
M M
Expand All @@ -42,21 +57,11 @@
M M 88 88 88. .88 88 88. .88 88 88 88
M M dP dP `8888P88 dP `88888P8 dP dP dP
MMMM .88
d8888P
""",

r"""
::::::::::: :::: ::: :::::::: ::::::::: ::: ::: :::
:+: :+:+: :+: :+: :+: :+: :+: :+: :+: :+:+: :+:+:
+:+ :+:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+:+ +:+
+#+ +#+ +:+ +#+ :#: +#++:++#: +#++:++#++: +#+ +:+ +#+
+#+ +#+ +#+#+# +#+ +#+# +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+#+# +# #+# #+# #+# #+# #+# #+# #+#
########### ### #### ######## ### ### ### ### ### ###
d8888P
""",

r"""
__ .__ __. _______ .______ ___ .___ ___.
__ .__ __. _______ .______ ___ .___ ___.
| | | \ | | / _____| | _ \ / \ | \/ |
| | | \| | | | __ | |_) | / ^ \ | \ / |
| | | . ` | | | |_ | | / / /_\ \ | |\/| |
Expand All @@ -77,24 +82,16 @@
8888888
888
888
888 88888b. .d88b. 888d888 8888b. 88888b.d88b.
888 888 "88b d88P"88b 888P" "88b 888 "888 "88b
888 888 888 888 888 888 .d888888 888 888 888
888 888 888 Y88b 888 888 888 888 888 888 888
8888888 888 888 "Y88888 888 "Y888888 888 888 888
888 88888b. .d88b. 888d888 8888b. 88888b.d88b.
888 888 "88b d88P"88b 888P" "88b 888 "888 "88b
888 888 888 888 888 888 .d888888 888 888 888
888 888 888 Y88b 888 888 888 888 888 888 888
8888888 888 888 "Y88888 888 "Y888888 888 888 888
888
Y8b d88P
"Y88P"
""",

r"""
___
|_ _| _ _ __ _ _ _ __ _ _ __
| | | ' \ / _` | | '_| / _` | | ' \
|___| |_||_| \__, | |_| \__,_| |_|_|_|
|___/
""",

r"""
|''||''|
||
Expand Down Expand Up @@ -155,13 +152,13 @@
""",

r"""
_|_|_|
_| _|_|_| _|_|_| _| _|_| _|_|_| _|_|_| _|_|
_| _| _| _| _| _|_| _| _| _| |_| _|
_| _| _| _| _| _| _| _| _| |_| _|
_|_|_| _| _| _|_|_| _| _|_|_| _| _| _|
_|
_|_|
_|_|_|
_| _|_|_| _|_|_| _| _|_| _|_|_| _|_|_| _|_|
_| _| _| _| _| _|_| _| _| _| |_| _|
_| _| _| _| _| _| _| _| _| |_| _|
_|_|_| _| _| _|_|_| _| _|_|_| _| _| _|
_|
_|_|
""",

r"""
Expand All @@ -185,12 +182,12 @@
""",

r"""
_/\/\/\/\______________________________________________________________________
___/\/\_____/\/\/\/\_______/\/\/\/\___/\/\__/\/\___/\/\/\_______/\/\/\__/\/\___
___/\/\_____/\/\__/\/\___/\/\__/\/\___/\/\/\/\_________/\/\_____/\/\/\/\/\/\/\_
___/\/\_____/\/\__/\/\_____/\/\/\/\___/\/\_________/\/\/\/\_____/\/\__/\__/\/\_
_/\/\/\/\___/\/\__/\/\_________/\/\___/\/\_________/\/\/\/\/\___/\/\______/\/\_
_________________________/\/\/\/\______________________________________________
_/\/\/\/\_________________________________________________________________
___/\/\____/\/\/\/\______/\/\/\/\__/\/\__/\/\__/\/\/\______/\/\/\__/\/\___
___/\/\____/\/\__/\/\__/\/\__/\/\__/\/\/\/\________/\/\____/\/\/\/\/\/\/\_
___/\/\____/\/\__/\/\____/\/\/\/\__/\/\________/\/\/\/\____/\/\__/\__/\/\_
_/\/\/\/\__/\/\__/\/\________/\/\__/\/\________/\/\/\/\/\__/\/\______/\/\_
_______________________/\/\/\/\___________________________________________
""",

r"""
Expand Down Expand Up @@ -224,12 +221,12 @@
""",

r"""
_/\/\/\/\______________________________________________________________________
___/\/\______/\/\/\/\_______/\/\/\/\___/\/\__/\/\___/\/\/\______/\/\/\__/\/\___
___/\/\______/\/\__/\/\___/\/\__/\/\___/\/\/\/\_________/\/\____/\/\/\/\/\/\/\_
___/\/\______/\/\__/\/\_____/\/\/\/\___/\/\_________/\/\/\/\____/\/\__/\__/\/\_
_/\/\/\/\____/\/\__/\/\_________/\/\___/\/\_________/\/\/\/\/\__/\/\______/\/\_
__________________________/\/\/\/\_____________________________________________
_/\/\/\/\____________________________________________________________________
___/\/\_____/\/\/\/\______/\/\/\/\___/\/\__/\/\___/\/\/\______/\/\/\__/\/\___
___/\/\_____/\/\__/\/\__/\/\__/\/\___/\/\/\/\_________/\/\____/\/\/\/\/\/\/\_
___/\/\_____/\/\__/\/\____/\/\/\/\___/\/\_________/\/\/\/\____/\/\__/\__/\/\_
_/\/\/\/\___/\/\__/\/\________/\/\___/\/\_________/\/\/\/\/\__/\/\______/\/\_
________________________/\/\/\/\____________________________________________
""",

r"""
Expand Down Expand Up @@ -314,8 +311,43 @@
]


logo = random.choice(logos)
def generate_logo() -> list:
"""concatenate the icon and font"""
icon = [i for i in ingram_icon.split('\n') if i.strip()]
icon_width = max([len(i) for i in icon])
icon_height = len(icon)

# do not longer than the terminal width!!!
found = False
for _ in range(100):
font = random.choice(ingram_fonts).split('\n')
font_width = max([len(i) for i in font])
font_height = len(font)
if font_width + icon_width + 2 < os.get_terminal_size()[0]:
found = True
break
if not found:
font = ['']
font_height = 1

if icon_height > font_height:
num = icon_height - font_height
if num & 1: head, tail = num // 2, num // 2 + 1
else: head, tail = num // 2, num // 2
font = [' '] * head + font + [' '] * tail

elif icon_height < font_height:
num = font_height - icon_height
if num & 1: head, tail = num // 2, num // 2 + 1
else: head, tail = num // 2, num // 2
icon = [' ' * icon_width] * head + icon + [' ' * icon_width] * tail

return [icon, font]


logo = generate_logo()


if __name__ == '__main__':
print(logo)
for left, right in zip(*logo):
print(f"{left} {right}")
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
```
___ ___ ___ ___ ___
___ / /\ / /\ / /\ / /\ / /\
/__/\ / /::| / /::\ / /::\ / /::\ / /::|
\__\:\ / /:|:| / /:/\:\ / /:/\:\ / /:/\:\ / /:|:|
/ /::\ / /:/|:|_ / /:/ \:\ / /::\ \:\ / /::\ \:\ / /:/|:|__
__/ /:/\/ /__/:/ |:| /\ /__/:/ __ \:\ /__/:/\:\_\:\ /__/:/\:\_\:\ /__/:/_|::::\
/__/\/:/ \__\/ |:|/:/ \ \:\/_/\ \/ \__\/ |::\/:/ \__\/ \:\/:/ \__\/ /~~/:/
\ \::/ | |:/:/ \ \:\ \:\ | |:|::/ \__\::/ / /:/
\ \:\ |__|::/ \ \:\/:/ | |:|\/ / /:/ / /:/
\__\/ /__/:/ \ \::/ |__|:| /__/:/ /__/:/
\__\/ \__\/ \__\| \__\/ \__\/
```


<div align=center>
<img alt="Ingram" src="https://github.com/jorhelp/Ingram/blob/master/statics/imgs/logo.png">
</div>
Expand Down
15 changes: 0 additions & 15 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
```
___ ___ ___ ___ ___
___ / /\ / /\ / /\ / /\ / /\
/__/\ / /::| / /::\ / /::\ / /::\ / /::|
\__\:\ / /:|:| / /:/\:\ / /:/\:\ / /:/\:\ / /:|:|
/ /::\ / /:/|:|_ / /:/ \:\ / /::\ \:\ / /::\ \:\ / /:/|:|__
__/ /:/\/ /__/:/ |:| /\ /__/:/ __ \:\ /__/:/\:\_\:\ /__/:/\:\_\:\ /__/:/_|::::\
/__/\/:/ \__\/ |:|/:/ \ \:\/_/\ \/ \__\/ |::\/:/ \__\/ \:\/:/ \__\/ /~~/:/
\ \::/ | |:/:/ \ \:\ \:\ | |:|::/ \__\::/ / /:/
\ \:\ |__|::/ \ \:\/:/ | |:|\/ / /:/ / /:/
\__\/ /__/:/ \ \::/ |__|:| /__/:/ /__/:/
\__\/ \__\/ \__\| \__\/ \__\/
```


<div align=center>
<img alt="Ingram" src="https://github.com/jorhelp/Ingram/blob/master/statics/imgs/logo.png">
</div>
Expand Down
57 changes: 28 additions & 29 deletions run_ingram.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

import argparse
import warnings
warnings.filterwarnings("ignore")

# from scan import scanner
# from utils.base import printf
# from utils.wechat import send_msg
from Ingram.utils.logo import logo
from Ingram.utils.color import color
from Ingram.utils.config import config
from Ingram.utils.time import get_current_time
from Ingram.utils.log import logger


def get_parser():
parser = argparse.ArgumentParser()
parser.add_argument('--in_file', type=str, required=True, help='the targets will be scan')
parser.add_argument('--out_path', type=str, required=True, help='the path where results will be saved')
parser.add_argument('--out_dir', type=str, required=True, help='the dir where results will be saved')
parser.add_argument('--debug', action='store_false', help='log all msg')

parser.add_argument('--th_num', type=int, default=80, help='the processes num')
parser.add_argument('--nosnap', action='store_false', help='do not capture the snapshot')
parser.add_argument('--debug', action='store_false', help='log all msg')
parser.add_argument('--time_out', type=int, default=2, help='requests timeout')

# masscan
parser.add_argument('--masscan', action='store_true', help='run massscan sanner')
parser.add_argument('--port', type=str, default=80, help='same as masscan port')
parser.add_argument('--rate', type=int, default=5000, help='same as masscan rate')
Expand All @@ -33,31 +33,30 @@ def get_parser():
return args


# def run(args):
# # readme
# flag, count = False, 0
# colors = ['red', 'cyan', 'green', 'blue', 'pink', 'white']
# with open('README.md', 'r') as f:
# for line in f:
# if line.startswith('#'): break
# if line.startswith('```'):
# if flag:
# print()
# count += 1
# flag = not flag
# elif flag: printf(line.rstrip(), color=colors[count % len(colors)], bold=True)
def run(args):
config.set_val('IN', args.in_file)
config.set_val('OUT', args.out_dir)
config.set_val('THNUM', args.th_num)
config.set_val('NOSNAP', args.nosnap)
config.set_val('DEBUG', args.debug)
config.set_val('TIMEOUT', args.time_out)

# # scan
# if args.masscan: scn = scanner.MasScaner(args)
# else: scn = scanner.CameraScanner(args)
# scn()

# # finished
# if args.send_msg: send_msg(f"{scn.scanner_name} finished!")
config.set_val('MAX_TRIES', 2) # since requests maybe failed, try N times
config.set_val('USERS', ['admin']) # user names for Brute force cracking of weak passwords
config.set_val('PASSWDS', ['admin', 'admin12345', 'asdf1234', 'abc12345', '12345admin', '12345abc'])
config.set_val('WXUID', '') # weechat uid used by wxpusher
config.set_val('WXTOKEN', '') # token used by wxpusher


if __name__ == '__main__':
args = get_parser()
warnings.filterwarnings("ignore")
# logo
for icon, font in zip(*logo):
print(f"{color.yellow(icon, 'bright')} {color.magenta(font, 'bright')}")
# args = get_parser()
# run(args)
print(color.magenta(logo, 'bright'))
print(color.yellow(str(get_current_time())))

# logger.info(config['USERS'])
# logger.warning(config['THNUM'])
# logger.error(config['IN'])
# logger.debug(config['OUT'])

0 comments on commit b469b84

Please sign in to comment.