mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-09-12 04:37:47 +02:00
Fix some bug on gitscan
This commit is contained in:
+11
-7
@@ -9,8 +9,8 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
||||
from core import utils
|
||||
|
||||
|
||||
# git_check -i /tmp/target.txt -o '$WORKSPACE/gitscan/$OUTPUT'
|
||||
# git_check - repo:sda
|
||||
# git_format -i /tmp/target.txt -o '$WORKSPACE/gitscan/$OUTPUT'
|
||||
# git_format -i 'repo:sda' -o '$WORKSPACE/gitscan/$OUTPUT'
|
||||
|
||||
def parse_input(data, out):
|
||||
repo = f'{out}-repo.txt'
|
||||
@@ -19,13 +19,17 @@ def parse_input(data, out):
|
||||
utils.just_append(repo, data.strip())
|
||||
else:
|
||||
key = data.split(':')[0]
|
||||
real_data = data.split(':')[1]
|
||||
real_data = ''.join(data.split(':')[1:])
|
||||
if 'user' in key or 'org' in key:
|
||||
utils.just_append(user, real_data.strip())
|
||||
utils.just_append(user, real_data + "\n")
|
||||
else:
|
||||
utils.just_append(repo, real_data.strip())
|
||||
utils.clean_up(repo)
|
||||
utils.clean_up(user)
|
||||
utils.just_append(repo, real_data + "\n")
|
||||
# print(real_data)
|
||||
try:
|
||||
utils.clean_up(repo)
|
||||
utils.clean_up(user)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def routine(args):
|
||||
|
||||
+6
-4
@@ -31,12 +31,14 @@ def routine(args):
|
||||
datas = [target]
|
||||
|
||||
if mode == 'user':
|
||||
for target in datas:
|
||||
cmd = f'{plugin}/go/gitrob -save {output} -threads 10 -github-access-token {key} {target}'
|
||||
for data in datas:
|
||||
cmd = f'{plugin}/go/gitrob -save {output} -threads 10 -github-access-token {key} {data}'
|
||||
utils.print_info(f"Execute: {cmd}")
|
||||
os.system(cmd)
|
||||
else:
|
||||
for target in datas:
|
||||
cmd = f'trufflehog --regex --entropy=True {target} | tee {output}-trufflehog.txt'
|
||||
for data in datas:
|
||||
cmd = f'trufflehog --regex --entropy=True {data} | tee {output}-trufflehog.txt'
|
||||
utils.print_info(f"Execute: {cmd}")
|
||||
os.system(cmd)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ def routine(args):
|
||||
cmd = f'sudo masscan --rate 10000 -p0-65535 -iL {target} -oX {output}.xml --wait 0'
|
||||
else:
|
||||
cmd = f'sudo masscan --rate 10000 -p0-65535 {target} -oX {output}.xml --wait 0'
|
||||
|
||||
|
||||
os.system(cmd)
|
||||
utils.print_info(f"Execute: {cmd}")
|
||||
|
||||
|
||||
+4
-2
@@ -107,7 +107,7 @@ def gen_default_config(config_path):
|
||||
configs.set('Enviroments', 'go_path', go_path)
|
||||
|
||||
# set some tokens
|
||||
github_api_key = utils.get_enviroment("GITROB_ACCESS_TOKEN")
|
||||
github_api_key = utils.get_enviroment("GITHUB_API_KEY")
|
||||
slack_bot_token = utils.get_enviroment("SLACK_BOT_TOKEN")
|
||||
log_channel = utils.get_enviroment("LOG_CHANNEL")
|
||||
status_channel = utils.get_enviroment("STATUS_CHANNEL")
|
||||
@@ -148,7 +148,9 @@ def load_default_config(config_file=None):
|
||||
'alias': key,
|
||||
'desc': key,
|
||||
}
|
||||
Configurations.objects.create(**item)
|
||||
instance, created = Configurations.objects.get_or_create(
|
||||
name=key)
|
||||
Configurations.objects.filter(name=key).update(**item)
|
||||
return options
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -587,7 +587,12 @@ def just_write(filename, data, is_json=False, uniq=False):
|
||||
def clean_up(filename):
|
||||
if not filename:
|
||||
return False
|
||||
data = just_read(filename, get_list=True)
|
||||
|
||||
filename = os.path.normpath(filename)
|
||||
if os.path.isfile(filename):
|
||||
with open(filename, 'r') as f:
|
||||
data = f.readlines()
|
||||
|
||||
real_data = list(set(data))
|
||||
just_write(filename, "\n".join(real_data))
|
||||
return True
|
||||
|
||||
@@ -10,7 +10,6 @@ from lib.mode import report
|
||||
|
||||
|
||||
def routine_handle(options):
|
||||
# print(options)
|
||||
if options.get('mode') == "report":
|
||||
utils.print_load("Running with report mode")
|
||||
report.handle(options)
|
||||
|
||||
@@ -342,7 +342,7 @@ class IPSpace:
|
||||
class GitScan:
|
||||
reports = [
|
||||
{
|
||||
"path": "$WORKSPACE/gitscan/$OUTPUT-repo.txt",
|
||||
"path": "$WORKSPACE/gitscan/$OUTPUT-user.txt",
|
||||
"type": "bash",
|
||||
},
|
||||
{
|
||||
@@ -355,22 +355,22 @@ class GitScan:
|
||||
'general': [
|
||||
{
|
||||
"banner": "parse input",
|
||||
"cmd": "$ALIAS_PATH/format_input -i '$TARGET' -o '$WORKSPACE/gitscan/$OUTPUT'",
|
||||
"output_path": "$WORKSPACE/gitscan/$OUTPUT-repo.txt",
|
||||
"cmd": "$ALIAS_PATH/git_format -i '$RAW_TARGET' -o '$WORKSPACE/gitscan/$OUTPUT'",
|
||||
"output_path": "$WORKSPACE/gitscan/$OUTPUT-user.txt",
|
||||
"std_path": "",
|
||||
"waiting": "first",
|
||||
},
|
||||
{
|
||||
"requirement": "$WORKSPACE/gitscan/$OUTPUT-repo.txt",
|
||||
"banner": "Git recon repo",
|
||||
"cmd": "$ALIAS_PATH/gitrecon -r $WORKSPACE/gitscan/$OUTPUT-repo.txt -o '$WORKSPACE/gitscan/$OUTPUT' -k '$GITHUB_API_KEY' -p '$PLUGIN_PATH' ",
|
||||
"cmd": "$ALIAS_PATH/gitrecon -r $WORKSPACE/gitscan/$OUTPUT-repo.txt -o '$WORKSPACE/gitscan/$OUTPUT' -k '$GITHUB_API_KEY' -p '$PLUGINS_PATH' ",
|
||||
"output_path": "$WORKSPACE/gitscan/$TARGET-gitrob.txt",
|
||||
"std_path": "$WORKSPACE/gitscan/std-$TARGET-gitrob.std"
|
||||
},
|
||||
{
|
||||
"requirement": "$WORKSPACE/gitscan/$OUTPUT-user.txt",
|
||||
"banner": "Git recon user",
|
||||
"cmd": "$ALIAS_PATH/gitrecon -u $WORKSPACE/gitscan/$OUTPUT-repo.txt -o '$WORKSPACE/gitscan/$OUTPUT' -k '$GITHUB_API_KEY' -p '$PLUGIN_PATH' ",
|
||||
"cmd": "$ALIAS_PATH/gitrecon -u $WORKSPACE/gitscan/$OUTPUT-user.txt -o '$WORKSPACE/gitscan/$OUTPUT' -k '$GITHUB_API_KEY' -p '$PLUGINS_PATH' ",
|
||||
"output_path": "$WORKSPACE/gitscan/$TARGET-gitrob.txt",
|
||||
"std_path": "$WORKSPACE/gitscan/std-$TARGET-gitrob.std"
|
||||
}
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ def load_default_config():
|
||||
# load command from default workflow
|
||||
dbutils.internal_parse_commands()
|
||||
# create server config file
|
||||
dbutils.load_default_config(confif_file='~/.osmedeus/server.conf')
|
||||
dbutils.load_default_config(config_file='~/.osmedeus/server.conf')
|
||||
# Configurations.objects.create(**record)
|
||||
utils.print_good("Load config success")
|
||||
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import django
|
||||
|
||||
# Load default path of extensions folder
|
||||
# WARNING: change this if you custom something
|
||||
BASE_DIR = Path(os.path.dirname(
|
||||
os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(str(BASE_DIR.joinpath('server')))
|
||||
|
||||
# loading django setup
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rest.settings")
|
||||
django.setup()
|
||||
|
||||
from api.models import *
|
||||
|
||||
from core import dbutils
|
||||
from core import utils
|
||||
|
||||
|
||||
# reload routine
|
||||
def reload_routine():
|
||||
# load command from default workflow
|
||||
dbutils.internal_parse_commands()
|
||||
# create server config file
|
||||
dbutils.load_default_config(config_file='~/.osmedeus/server.conf')
|
||||
|
||||
|
||||
def main(args):
|
||||
# workspace = args.workspace if args.workspace else None
|
||||
utils.print_block("Reload routine and config for server", tag='RUN')
|
||||
reload_routine()
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="Reload routine for server")
|
||||
parser.add_argument('-w', '--workspace', action='store',
|
||||
dest='workspace', help='workspace')
|
||||
args = parser.parse_args()
|
||||
main(args)
|
||||
@@ -9,7 +9,7 @@ from core import utils
|
||||
|
||||
# store some configuration
|
||||
class Configurations(models.Model):
|
||||
name = models.TextField(blank=False, default='')
|
||||
name = models.TextField(unique=True, blank=False, default='')
|
||||
value = models.TextField(blank=False, default='')
|
||||
alias = models.TextField(default='')
|
||||
desc = models.TextField(default='')
|
||||
|
||||
Reference in New Issue
Block a user