|
import gradio as gr |
|
from utils.gradio_utils import * |
|
import os |
|
import pandas as pd |
|
import matplotlib.pyplot as plt |
|
import seaborn as sns |
|
from dotenv import load_dotenv |
|
|
|
load_dotenv(dotenv_path=".env", override=True) |
|
|
|
USER = os.getenv("USERNAME") |
|
PASS = os.getenv("PASSWORD") |
|
|
|
|
|
list_iface = gr.Interface(fn=compute_offer, |
|
inputs=[gr.File(label="Upload CSV", type="filepath"), |
|
gr.Slider(0, 365, value=3, step=1, label="Days", info="Number of days to look back"), |
|
gr.Slider(5000, 10000000, value=1000000, step=1, label="Minimum Sent", info="Minimum number of emails sent"), |
|
gr.Dropdown(["Comcast", "Yahoo", "Hotmail", "Aol"], value="Yahoo", label="Domain"), |
|
gr.Dropdown(["All", "Team 1", "Team 2"], value="Team 2", label="Team"), |
|
gr.Radio(["Newsletters", "Offers", 'Offers - IDs only'], label="Type", value="Offers - IDs only"), |
|
gr.Textbox(label="Exclude list", info="Example: INH,MNP", value="INH,DHI,HHP,RTA,JVR,HTH,FNC,SCD,ENH,WIP")], |
|
outputs="dataframe") |
|
|
|
|
|
def plot_df(filename): |
|
|
|
df = pd.read_csv(filename.name) |
|
df["timeLogged"] = pd.to_datetime(df["timeLogged"]) |
|
zztitle = filename.name.split('_')[1] |
|
|
|
fig, ax = plt.subplots(figsize=(20, 10)) |
|
sns.lineplot(x='timeLogged', y='delivered', hue='dlvSourceIp', data=df.reset_index()) |
|
|
|
ax.set_title(zztitle) |
|
ax.set_ylabel('Number of emails delivered') |
|
ax.set_xlabel('Date') |
|
ax.legend(loc='upper left') |
|
|
|
plt.xticks(rotation=90) |
|
return fig |
|
|
|
|
|
plt_iface = gr.Interface(fn=plot_df, |
|
inputs=gr.File(label="Upload CSV", type="filepath"), |
|
outputs=gr.Plot()) |
|
|
|
|
|
|
|
domains_template = """ |
|
example.com |
|
""" |
|
|
|
|
|
with gr.Blocks() as aeon: |
|
with gr.Tab(label="SWAKS"): |
|
with gr.Row(): |
|
with gr.Column(): |
|
ip_addresses_raw = gr.Textbox(lines=2, value="192.168.1.1/24", label="IP Classes") |
|
with gr.Column(): |
|
with gr.Row(): |
|
with gr.Column(): |
|
max_ips = gr.Number(value=0, label="Max IPs to search for before stopping") |
|
with gr.Column(): |
|
sample_size = gr.Number(value=5, label="Number of commands per subdomain") |
|
domains = gr.Textbox(lines=5, max_lines=5,value=domains_template, label="Domains") |
|
with gr.Row(): |
|
header_box = gr.Textbox(label="Header Used to Create Commands", visible=False) |
|
max_ips.change(fn=update_header, inputs=max_ips, outputs=header_box) |
|
with gr.Row(): |
|
with gr.Column(): |
|
|
|
gen_cmds_btn = gr.Button("Generate Commands") |
|
|
|
|
|
with gr.Row(): |
|
cmds = gr.Code(lines=20, value="Generate Commands") |
|
|
|
gen_cmds_btn.click(fn=generate_cmds_from_bulk, inputs=[ip_addresses_raw, domains, max_ips, sample_size], outputs=[cmds]) |
|
|
|
with gr.Accordion("Tips and tricks"): |
|
gr.Markdown("""The subdomains are IPs from [1-19] and [201-254]. |
|
- Copy the commands and copy them in a file `nano check.sh` and paste and save. |
|
- Run in terminal `sh check.sh` and wait for it to finish |
|
- There will two types of files: `bune_IP_addr.txt` and `blocate_IP_addr.txt` |
|
- To get all the good IPs run: `cat bune*` |
|
""") |
|
|
|
|
|
with gr.Tab(label="Mix domains and IPs"): |
|
with gr.Row(): |
|
with gr.Column(): |
|
ip_subclasses_raw = gr.Textbox(label="IP Subclasses plain text", \ |
|
value="""192.168.1.1/24""", lines=2) |
|
with gr.Column(): |
|
num_of_ips = gr.Number(label="Number of IPs per /24", value=4) |
|
with gr.Row(): |
|
domains_raw = gr.Textbox(label="Domains", value="gogu.com\nasd.com\ndsa.com\ngigi.com") |
|
greet_btn = gr.Button("Compute IPs") |
|
output_ips = gr.Textbox(label="List of IPs") |
|
|
|
greet_btn.click(fn=generate_ips_per_subclass, inputs=[ip_subclasses_raw, num_of_ips],\ |
|
outputs=output_ips) |
|
|
|
|
|
output_mix = gr.Code(label="Mixed IPs and Domains") |
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
reset_btn = gr.ClearButton(value="Reset", components=[ip_subclasses_raw, domains_raw]) |
|
with gr.Column(): |
|
mix_btn = gr.Button("Mix IPs and Domains") |
|
mix_btn.click(fn=mix, inputs=[domains_raw, output_ips, num_of_ips], |
|
outputs=output_mix) |
|
|
|
with gr.Tab(label="Top Lists"): |
|
list_iface.render() |
|
|
|
with gr.Tab(label="Plot"): |
|
plt_iface.render() |
|
|
|
aeon.launch(auth=(USER, PASS)) |