mazepa.git


mazepa

~ linux userland keylogger
git clone https://github.com/djnnvx/mazepa.git
log | files | refs | archive | README

commit 10dfdb796ef24e3348f9124e2135330e862e6846
parent 30e300cba99876c190afc912542218fa202ecafb
Author: bogdzn <[email protected]>
Date: Mon, 11 Oct 2021 00:11:18 +0200

(mod/server)removing TUIs

Diffstat:
Dserver/interface.py | 116-------------------------------------------------------------------------------
Dserver/test.py | 239-------------------------------------------------------------------------------

2 files changed, 0 insertions(+), 355 deletions(-)

diff --git a/server/interface.py b/server/interface.py
@@ -1,116 +0,0 @@
-#!/usr/bin/env python3
-
-from asciimatics.effects import Julia
-from asciimatics.widgets import Frame, Layout, Divider, Button, Text, ListBox, Widget
-from asciimatics.scene import Scene
-from asciimatics.screen import Screen
-from asciimatics.exceptions import ResizeScreenError, NextScene, StopApplication
-import sys
-import pandas as pd
-
-
-class TabButtons(Layout):
-    def __init__(self, frame, active_tab_idx):
-        cols = [1, 1, 1, 1, 1]
-        super().__init__(cols)
-        self._frame = frame
-        for i,_ in enumerate(cols):
-            self.add_widget(Divider(), i)
-        btns = [Button("Btn1", self._on_click_1),
-                Button("Btn2", self._on_click_2),
-                Button("Btn3", self._on_click_3),
-                Button("Btn4", self._on_click_4),
-                Button("Quit", self._on_click_Q)]
-        for i, btn in enumerate(btns):
-            self.add_widget(btn, i)
-        btns[active_tab_idx].disabled = False
-
-    def _on_click_1(self):
-        raise NextScene("Tab1")
-
-    def _on_click_2(self):
-        raise NextScene("Tab2")
-
-    def _on_click_3(self):
-        raise NextScene("Tab3")
-
-    def _on_click_4(self):
-        raise NextScene("Tab4")
-
-    def _on_click_Q(self):
-        raise StopApplication("Quit")
-
-
-class KeyLogScene(Frame):
-    def __init__(self, screen, name, df):
-        super().__init__(screen,
-                         screen.height,
-                         screen.width,
-                         can_scroll=False,
-                         title=name)
-        layout1 = Layout([1], fill_frame=True)
-        self.add_layout(layout1)
-        # add your widgets here
-        layout1.add_widget(ListBox(Widget.FILL_FRAME, name="something", options=[("IP:" + str(name), 1), ("Logs:" + str(df), 2)]))
-
-        layout2 = TabButtons(self, 0)
-        self.add_layout(layout2)
-        self.fix()
-
-class KeyLogFrame(Frame):
-    def __init__(self, screen, x, y, i, name, df):
-        super().__init__(screen,
-                         screen.height // find_height_divider(i, 3),
-                         screen.width // find_width_divider(i, 3),
-                         can_scroll=True,
-                         title=name,
-                         x=x * screen.width // find_width_divider(i, 3),
-                         y=(y - 1) * screen.height // find_height_divider(i, 3))
-        layout = Layout([1], fill_frame=True)
-        self.add_layout(layout)
-        layout.add_widget(ListBox(Widget.FILL_FRAME, name="something", options=[("IP:" + str(name), 1), ("Logs:" + str(df), 2)]))
-        layout2 = TabButtons(self, 0)
-        self.add_layout(layout2)
-        self.fix()
-
-def find_height_divider(num, max_on_line):
-    if (num // max_on_line < 1):
-        return 1
-    else:
-        return num // max_on_line
-
-def find_width_divider(num, max_on_line):
-    if num < max_on_line:
-        return num
-    else:
-        return max_on_line
-
-def demo(screen, scene):
-    try:
-        df = pd.read_csv(".keylogs.csv")
-    except FileNotFoundError:
-        df = None
-    dc = df.to_dict()
-
-    dc_len = len(dc)
-    scenes = []
-    effects = []
-    y = 0
-    x = 0
-    for index, key in enumerate(dc):
-        x += 1
-        if (index % 3 == 0):
-            y += 1
-            x = 0
-        effects.append(KeyLogFrame(screen, x, y, dc_len, key, dc[key]))
-    scenes.append(Scene(effects, -1))
-    screen.play(scenes, stop_on_resize=True, start_scene=scene, allow_int=True)
-
-last_scene = None
-while True:
-    try:
-        Screen.wrapper(demo, catch_interrupt=False, arguments=[last_scene])
-        sys.exit(0)
-    except ResizeScreenError as e:
-        last_scene = e.scene
-
diff --git a/server/test.py b/server/test.py
@@ -1,239 +0,0 @@
-# !/usr/bin/env python3
-
-import curses
-import curses.textpad
-import pandas as pd
-import sys
-
-
-class Screen(object):
-    UP = -1
-    DOWN = 1
-
-    def __init__(self, items):
-        """ Initialize the screen window
-        Attributes
-            window: A full curses screen window
-            width: The width of `window`
-            height: The height of `window`
-            max_lines: Maximum visible line count for `result_window`
-            top: Available top line position for current page (used on scrolling)
-            bottom: Available bottom line position for whole pages (as length of items)
-            current: Current highlighted line number (as window cursor)
-            page: Total page count which being changed corresponding to result of a query (starts from 0)
-            ┌--------------------------------------┐
-            |1. Item                               |
-            |--------------------------------------| <- top = 1
-            |2. Item                               |
-            |3. Item                               |
-            |4./Item///////////////////////////////| <- current = 3
-            |5. Item                               |
-            |6. Item                               |
-            |7. Item                               |
-            |8. Item                               | <- max_lines = 7
-            |--------------------------------------|
-            |9. Item                               |
-            |10. Item                              | <- bottom = 10
-            |                                      |
-            |                                      | <- page = 1 (0 and 1)
-            └--------------------------------------┘
-        Returns
-            None
-        """
-        self.window = None
-
-        self.width = 0
-        self.height = 0
-
-        self.active_conv_status = 'Disconnected'
-
-        self.init_curses()
-
-        self.items = items
-        self.current_ip = self.items[0]
-        self.max_item_len = max([len(i) for i in items])
-
-        self.max_lines = curses.LINES
-        self.top = 0
-        self.bottom = len(self.items)
-        self.current = 0
-        self.page = self.bottom // self.max_lines
-
-    def init_curses(self):
-        """Setup the curses"""
-        self.window = curses.initscr()
-        self.window.keypad(True)
-
-        curses.noecho()
-        curses.cbreak()
-
-        curses.start_color()
-        curses.init_pair(1, curses.COLOR_CYAN, curses.COLOR_BLACK)
-        curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_CYAN)
-        curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)
-        curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK)
-        curses.init_pair(5, curses.COLOR_GREEN, curses.COLOR_CYAN)
-        self.current = curses.color_pair(2)
-
-        self.height, self.width = self.window.getmaxyx()
-
-    def run(self):
-        """Continue running the TUI until get interrupted"""
-        try:
-            self.input_stream()
-        except KeyboardInterrupt:
-            pass
-        finally:
-            curses.endwin()
-
-    def input_stream(self):
-        """Waiting an input and run a proper method according to type of input"""
-        while True:
-            self.display()
-
-            ch = self.window.getch()
-            if ch == curses.KEY_UP:
-                self.scroll(self.UP)
-            elif ch == curses.KEY_DOWN:
-                self.scroll(self.DOWN)
-            elif ch == curses.KEY_LEFT:
-                self.paging(self.UP)
-            elif ch == curses.KEY_RIGHT:
-                self.paging(self.DOWN)
-            elif ch == curses.KEY_EXIT:
-                break
-
-    def scroll(self, direction):
-        """Scrolling the window when pressing up/down arrow keys"""
-        # next cursor position after scrolling
-        next_line = self.current + direction
-
-        # Up direction scroll overflow
-        # current cursor position is 0, but top position is greater than 0
-        if (direction == self.UP) and (self.top > 0 and self.current == 0):
-            self.top += direction
-            return
-        # Down direction scroll overflow
-        # next cursor position touch the max lines, but absolute position of max lines could not touch the bottom
-        if (direction == self.DOWN) and (next_line == self.max_lines) and (self.top + self.max_lines < self.bottom):
-            self.top += direction
-            return
-        # Scroll up
-        # current cursor position or top position is greater than 0
-        if (direction == self.UP) and (self.top > 0 or self.current > 0):
-            self.current = next_line
-            return
-        # Scroll down
-        # next cursor position is above max lines, and absolute position of next cursor could not touch the bottom
-        if (direction == self.DOWN) and (next_line < self.max_lines) and (self.top + next_line < self.bottom):
-            self.current = next_line
-            return
-
-    def paging(self, direction):
-        """Paging the window when pressing left/right arrow keys"""
-        current_page = (self.top + self.current) // self.max_lines
-        next_page = current_page + direction
-        # The last page may have fewer items than max lines,
-        # so we should adjust the current cursor position as maximum item count on last page
-        if next_page == self.page:
-            self.current = min(self.current, self.bottom % self.max_lines - 1)
-
-        # Page up
-        # if current page is not a first page, page up is possible
-        # top position can not be negative, so if top position is going to be negative, we should set it as 0
-        if (direction == self.UP) and (current_page > 0):
-            self.top = max(0, self.top - self.max_lines)
-            return
-        # Page down
-        # if current page is not a last page, page down is possible
-        if (direction == self.DOWN) and (current_page < self.page):
-            self.top += self.max_lines
-            return
-
-    def display_status_bar(self):
-        # Render status bar
-        height, width = self.window.getmaxyx()
-        self.window.attron(curses.color_pair(3))
-        status = f'ip:{self.current_ip} | Status : {self.active_conv_status} | Press Q for Quit'
-        self.window.addstr(height - 1, 0, status)
-        self.window.addstr(height - 1, len(status), " " * (width - len(status) - 1))
-        self.window.attroff(curses.color_pair(3))
-
-
-    def display_bubble_speach(self, box):
-        df = pd.read_csv('.keylogs.csv')
-        idx = 2
-        cur_y = 2
-        for i, row in enumerate(df[self.current_ip]):
-            row = str(row)
-            if not row:
-                continue
-            if (row == '200 NEW CONNEXION'):
-                self.active_conv_status = 'Alive'
-                continue
-            elif (row == '500 KO'):
-                self.active_conv_status = 'Disconnected'
-                continue
-            content = row.split('\n')[:-1]
-            time = row.split('\n')[-1]
-            if i % 2:
-                tail = 'L'
-            else:
-                tail = 'R'
-            bubble = "╭─" + "─" * 50 + "─╮\n"
-            for line in content:
-                filler = " " * (50 - len(line))
-                bubble += "│ " + line + filler + " │\n"
-            bubble += "╰─" + "─" * 50 + "─╯"
-            if tail == "L":
-                bubble += "\n"
-                bubble += "  )/  \n"
-                bubble += "-\"`\n"
-            elif tail == "R":
-                bubble += "\n"
-                bubble += (" " * 50) + "\\(  \n"
-                bubble += (" " * 50) + " `\"-\n"
-            for j, line in enumerate(bubble.split('\n')):
-                if (j + idx * 3 >= curses.LINES):
-                    return
-                cur_y = j + idx * 3
-                box.addstr(j + idx * 3, 4 if tail == 'L' else 70, line, curses.color_pair(2))
-            if (cur_y + 1 >= curses.LINES):
-                return
-            box.addstr(cur_y, 50 - len(time) - 1 if tail == 'L' else 120 - len(time) -1, time, curses.color_pair(2))
-            idx += 1
-
-    def display(self):
-        """Display the items on window"""
-        self.window.erase()
-        box = None
-        height, width = self.window.getmaxyx()
-        for idx, item in enumerate(self.items[self.top:self.top + self.max_lines]):
-            # Highlight the current cursor line
-            if idx == self.current:
-                self.window.addstr(idx, 0, item, curses.color_pair(2))
-                box = curses.newwin(height, width - self.max_item_len, 0, self.max_item_len + 1)
-                box.bkgd(' ', curses.color_pair(2) | curses.A_BOLD)
-                box.box()
-                self.current_ip = item
-                self.display_bubble_speach(box)
-            else:
-                self.window.addstr(idx, 0, item.ljust(self.max_item_len), curses.color_pair(1))
-
-        self.window.refresh()
-        if box:
-            box.refresh()
-            del box
-        self.display_status_bar()
-
-
-
-def main():
-    df = pd.read_csv('.keylogs.csv')
-    items = list(filter(lambda x: ("Unnamed: 0" not in x), df.columns))
-    screen = Screen(items)
-    screen.run()
-
-
-if __name__ == '__main__':
-    main()