Add files via upload

main
witchdocsec 2024-06-11 21:52:54 +01:00 committed by GitHub
commit 5d64413e9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 144 additions and 0 deletions

25
README.md Normal file
View File

@ -0,0 +1,25 @@
# massiprecon
Given a list of ips massiprecon will find location and provider info etc and write them to a csv or json
## useage (standalone)
```
usage: py -m massiprecon -i INFILE -o OUTFILE
massiprecon args
options:
-h, --help show this help message and exit
-i INFILE, --infile INFILE
list of ips
-o OUTFILE, --outfile OUTFILE
json or csv file to write to
```
## useage (library)
```
from massiprecon import massiprecon
f=massiprecon.FileMaker(args.infile,args.outfile)
print(f.generate())
```

1
massiprecon/__innit__.py Normal file
View File

@ -0,0 +1 @@

30
massiprecon/__main__.py Normal file
View File

@ -0,0 +1,30 @@
from massiprecon import massiprecon
if __name__ == "__main__":
# Importing argparse
print(''' _____ ______ ________ ________ ________ ___ ________ ________ _______ ________ ________ ________
|\\ _ \\ _ \\|\\ __ \\|\\ ____\\ |\\ ____\\|\\ \\|\\ __ \\|\\ __ \\|\\ ___ \\ |\\ ____\\|\\ __ \\|\\ ___ \\
\\ \\ \\\\\\__\\ \\ \\ \\ \\|\\ \\ \\ \\___|_\\ \\ \\___|\\ \\ \\ \\ \\|\\ \\ \\ \\|\\ \\ \\ __/|\\ \\ \\___|\\ \\ \\|\\ \\ \\ \\\\ \\ \\
\\ \\ \\\\|__| \\ \\ \\ __ \\ \\_____ \\\\ \\_____ \\ \\ \\ \\ ____\\ \\ _ _\\ \\ \\_|/_\\ \\ \\ \\ \\ \\\\\\ \\ \\ \\\\ \\ \\
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\|____|\\ \\\\|____|\\ \\ \\ \\ \\ \\___|\\ \\ \\\\ \\\\ \\ \\_|\\ \\ \\ \\____\\ \\ \\\\\\ \\ \\ \\\\ \\ \\
\\ \\__\\ \\ \\__\\ \\__\\ \\__\\____\\_\\ \\ ____\\_\\ \\ \\__\\ \\__\\ \\ \\__\\\\ _\\\\ \\_______\\ \\_______\\ \\_______\\ \\__\\\\ \\__\\
\\|__| \\|__|\\|__|\\|__|\\_________\\\\_________\\|__|\\|__| \\|__|\\|__|\\|_______|\\|_______|\\|_______|\\|__| \\|__|
\\|_________\\|_________| ''')
import argparse
# Define the parser function
def parser():
# Create the base argument parser
parser = argparse.ArgumentParser(description="massiprecon args")
parser.add_argument("-i", "--infile", required=True, help="list of ips")
parser.add_argument("-o", "--outfile", required=True, help="json or csv file to write to")
# Return parsed arguments
args = parser.parse_args()
return args
args = parser()
f=massiprecon.FileMaker(args.infile,args.outfile)
print(f.generate())

View File

@ -0,0 +1,55 @@
#imports
import csv
import requests
import json
#internal function for removing keys
def keystripper(rows):
rows=[ [ str(value) for value in row.values() ] for row in rows ]
return rows
class FileMaker:
#initialise FileMaker object
def __init__(self,iplist,outfile):
self.iplist=iplist
self.outfile=outfile
#parse extension
self.filetype=outfile.split(".")[-1].lower()
#generator function
def generate(self):
#open iplist file
with open(self.iplist, "r") as iplist:
rows=[]
for ip in iplist:
ip=ip.replace("\n","")
#query api
r=requests.post(f"http://ip-api.com/json/{ip}?fields=status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,offset,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query")
rows.append(json.loads(r.text))
#write to json
if self.filetype == "json":
with open(self.outfile, "w", newline='\n') as outf:
outf.write(json.dumps(rows))
return "written to json"
#write to csv
elif self.filetype == "csv":
with open(self.outfile, "w", newline='\n') as outf:
selected=rows[0]
fields = [ key for key in selected.keys()]
rows=keystripper(rows)
writer = csv.writer(outf, delimiter=",")
writer.writerow(fields)
writer.writerows(rows)
return "written to csv"
#invalid extension
else:
return "extension must be json or csv"

33
setup.py Normal file
View File

@ -0,0 +1,33 @@
from setuptools import setup
import codecs
import os
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
long_description = "\n" + fh.read()
VERSION = '0.0.11'
DESCRIPTION = 'Generate csv or jsons with ip info'
LONG_DESCRIPTION = 'Given a list of ips massiprecon will find location and provider info etc and write them to a csv or json'
# Setting up
setup(
name="massiprecon",
version=VERSION,
author="Witchdoctor (malectrica)",
description=DESCRIPTION,
long_description_content_type="text/markdown",
long_description=long_description,
packages=['massiprecon'],
install_requires=['argparse'],
keywords=['python', 'hack', 'osint', 'recon', 'data', 'api', 'ip'],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
]
)