File size: 4,620 Bytes
236f43c
 
79f993e
491fe7e
 
 
144c5a1
 
 
058edcf
59ed8ba
 
430c2f6
59961c2
058edcf
 
59961c2
 
058edcf
 
 
491fe7e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236f43c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dde30fa
 
 
 
 
 
2f6c49d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491fe7e
2f6c49d
 
058edcf
 
491fe7e
 
 
236f43c
430c2f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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="file"),
                    gr.Slider(1, 365, value=30, step=1, label="Days", info="Number of days to look back"),
                    gr.Slider(5000, 100000, value=15000, step=1, label="Minimum Sent", info="Minimum number of emails sent")
                    ],
            outputs="dataframe")

# PLOTTING
def plot_df(filename):
    # Read the file into a pandas DataFrame
    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())
    # set x axis extract only hour and minute from datetime
    ax.set_title(zztitle)
    ax.set_ylabel('Number of emails delivered')
    ax.set_xlabel('Date')
    ax.legend(loc='upper left')
    # allign ticks at 45 degrees
    plt.xticks(rotation=90)
    return fig


plt_iface =  gr.Interface(fn=plot_df, 
                    inputs=gr.File(label="Upload CSV", type="file"), 
                    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(label="Generate Commands")
                
            # with gr.Column():
            #     reset_btn = gr.ClearButton(components=[ip_subclasses_raw, num_of_ips, domains_raw])
        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(label="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))