|
32 | 32 | # Author: oxagast |
33 | 33 | # Import standard and third-party libraries for argument parsing, file handling, networking, compression, and data processing |
34 | 34 | import warnings |
35 | | - |
36 | | -warnings.simplefilter("module") |
37 | | -os.environ["PYTHONWARNINGS"] = "module" |
38 | | -warnings.formatwarning = lambda msg, cat, fname, ln, file=None, line=None: ( |
39 | | - f"[Main] {cat.__name__} {msg}\n" |
40 | | -) |
41 | 35 | import argparse |
42 | 36 | import base64 |
43 | 37 | import csv |
|
52 | 46 | import threading |
53 | 47 | import time |
54 | 48 | import zlib |
55 | | -from urllib.parse import unquote_plus |
56 | | -from datetime import datetime |
57 | | -from decimal import Decimal |
58 | | -from functools import lru_cache |
59 | 49 | import chardet |
60 | 50 | import geoip2.database |
61 | 51 | import magic |
62 | 52 | import numpy as np |
63 | 53 | import ollama |
64 | 54 | import requests |
65 | 55 | import yaml |
66 | | - |
67 | | - |
68 | | -# from tqdm import tqdm |
69 | 56 | import ipaddress |
70 | 57 | from bs4 import BeautifulSoup |
71 | 58 | from ollama import ResponseError |
72 | 59 | from scipy.stats import entropy |
73 | 60 | from concurrent.futures import ThreadPoolExecutor, as_completed |
| 61 | +from urllib.parse import unquote_plus |
| 62 | +from datetime import datetime |
| 63 | +from decimal import Decimal |
| 64 | +from functools import lru_cache |
74 | 65 |
|
| 66 | + |
| 67 | +warnings.simplefilter("module") |
| 68 | +os.environ["PYTHONWARNINGS"] = "module" |
| 69 | +warnings.formatwarning = lambda msg, cat, fname, ln, file=None, line=None: ( |
| 70 | + f"[Main] {cat.__name__} {msg}\n" |
| 71 | +) |
75 | 72 | stopEvent = threading.Event() |
76 | 73 |
|
77 | 74 | try: |
@@ -3301,10 +3298,6 @@ def startThreading(): |
3301 | 3298 | amounts of time (e.g. when active-recon network calls vary in latency). |
3302 | 3299 | """ |
3303 | 3300 | if __name__ == "__main__": |
3304 | | - print( |
3305 | | - f"[Main] Spooling up {numWorkerThreads} worker threads to process {totalPackets} packets...", |
3306 | | - file=sys.stderr, |
3307 | | - ) |
3308 | 3301 | # Build the list of packet indices that belong to TCP, UDP, or ICMP packets |
3309 | 3302 | packetIndices = [ |
3310 | 3303 | i |
@@ -3436,7 +3429,6 @@ def processChunk(chunk): |
3436 | 3429 | "server_call_threads": 5, |
3437 | 3430 | "batch_size": 65, |
3438 | 3431 | }, |
3439 | | - "threads": 16, |
3440 | 3432 | "final_summary": True, |
3441 | 3433 | } |
3442 | 3434 | pcapFilePath = args.pcap_file |
@@ -3493,8 +3485,7 @@ def processChunk(chunk): |
3493 | 3485 | if totalPackets == 0: |
3494 | 3486 | print("[Main] No TCP, UDP, or ICMP packets found in the capture.", file=sys.stderr) |
3495 | 3487 | sys.exit(1) |
3496 | | -if "threads" in config and config["threads"]: |
3497 | | - numWorkerThreads = config["threads"] |
| 3488 | +numWorkerThreads = os.cpu_count() or 4 |
3498 | 3489 | outputDir = currentDir + "/" + "testcases" |
3499 | 3490 | if args.output and args.output != "testcases": |
3500 | 3491 | outputDir = args.output |
@@ -3537,7 +3528,6 @@ def processChunk(chunk): |
3537 | 3528 | "use_llm": False, |
3538 | 3529 | "llm_brief": False, |
3539 | 3530 | }, |
3540 | | - "threads": 16, |
3541 | 3531 | "final_summary": False, |
3542 | 3532 | } |
3543 | 3533 |
|
|
0 commit comments