Skip to content

Commit ff109bd

Browse files
committed
chore: eliminate all 60 flake8 violations (60 → 0)
- Remove 46 unused imports across 15 core/ files and 4 handlers/ files - Fix 2 F821 bugs: add missing `import platform` in advanced_techniques, add TYPE_CHECKING import for DockerExecutor in sandbox/fallback - Fix 2 F541: remove f-prefix from strings without placeholders in http/client - Fix F841: remove unused `tools` variable in resource_handlers - Fix E261/E302/E303: whitespace formatting in beacon, credential_dumper, resource_handlers - Add noqa: F401 for 8 intentional conditional imports (impacket, lazagne, httpx, requests, aiohttp, docker, urllib3 — optional dependency guards) - Consolidate duplicate typing imports in ad_enum, sandbox/executor
1 parent 39ac2f8 commit ff109bd

23 files changed

Lines changed: 32 additions & 55 deletions

‎core/ad/ad_enum.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313
注意: 仅用于授权的渗透测试和安全研究
1414
"""
1515

16-
import logging
17-
from typing import List, Optional
18-
19-
logger = logging.getLogger(__name__)
20-
2116
import base64
2217
import json
18+
import logging
2319
import re
2420
import socket
2521
import ssl
@@ -28,6 +24,8 @@
2824
from enum import Enum
2925
from typing import Any, Dict, List, Optional, Tuple
3026

27+
logger = logging.getLogger(__name__)
28+
3129

3230
class ADObjectType(Enum):
3331
"""AD对象类型"""

‎core/ad/kerberos_attacks.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def golden_ticket(
436436
Returns:
437437
AttackResult包含生成的票据
438438
"""
439-
from impacket.krb5.ticket import Ticket as TicketClass
439+
from impacket.krb5.ticket import Ticket as TicketClass # noqa: F401
440440

441441
if groups is None:
442442
# 默认高权限组
@@ -458,10 +458,9 @@ def golden_ticket(
458458
nt_hash = bytes.fromhex(krbtgt_hash)
459459

460460
# 使用 impacket ticketer 生成 Golden Ticket
461-
from impacket.krb5 import constants as krb5_constants
462-
from impacket.krb5.types import KerberosTime, Principal
461+
from impacket.krb5 import constants as krb5_constants # noqa: F401
462+
from impacket.krb5.types import KerberosTime, Principal # noqa: F401
463463

464-
import datetime
465464
import os
466465

467466
# 构建 ticketer 命令参数 — 通过 impacket 的 ticketer 模块
@@ -574,7 +573,7 @@ def silver_ticket(
574573
Returns:
575574
AttackResult包含生成的票据
576575
"""
577-
from impacket.krb5.ticket import Ticket as TicketClass
576+
from impacket.krb5.ticket import Ticket as TicketClass # noqa: F401
578577

579578
if groups is None:
580579
groups = [513, 512, 520, 518, 519]

‎core/c2/beacon.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@
1414
"""
1515

1616
import asyncio
17-
import hashlib
1817
import ipaddress
19-
import json
2018
import re
2119
import logging
2220
import os
2321
import platform
24-
import secrets
2522
import socket
2623
import ssl
2724
import subprocess
2825
import tempfile
2926
import threading
3027
import time
31-
import uuid
3228
from dataclasses import dataclass, field
3329
from enum import Enum
3430
from typing import Any, Dict, List, Optional, Tuple
@@ -103,7 +99,7 @@ class BeaconConfig(C2Config):
10399
r">\s*/dev/sd", # 覆写磁盘设备
104100
r"format\s+[a-zA-Z]:", # Windows format
105101
r":\(\)\s*\{", # fork bomb
106-
r"shutdown|reboot|halt|poweroff", # 系统控制命令
102+
r"shutdown|reboot|halt|poweroff", # 系统控制命令
107103
]
108104
)
109105

‎core/config/models.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
from __future__ import annotations
1919

20-
from pathlib import Path
21-
from typing import Any, Dict, List, Optional, Tuple
20+
from typing import Dict, List
2221

2322
from pydantic import BaseModel, Field
2423

‎core/credential/credential_dumper.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ def export_json(self, output_path: Optional[str] = None) -> str:
791791
else:
792792
return json.dumps(data, indent=2, ensure_ascii=False)
793793

794-
795794
def dump_lazagne(self) -> DumpResult:
796795
"""
797796
LaZagne 集成 — 调用 LaZagne 进行全平台凭据提取
@@ -813,7 +812,7 @@ def dump_lazagne(self) -> DumpResult:
813812
# 尝试作为 Python 模块调用
814813
if not lazagne_path:
815814
try:
816-
import lazagne as _lz
815+
import lazagne as _lz # noqa: F401
817816

818817
lazagne_path = "module"
819818
except ImportError:

‎core/engine_router.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ def __init__(self, sqlmap_path: Path, **kwargs):
181181

182182
async def scan(self, target: str, **kwargs) -> dict:
183183
import asyncio
184-
import json
185184
import subprocess
186185
import sys
187186

‎core/exploit/pure_sqli.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
# HTTP 请求库
2121
try:
22-
import httpx
22+
import httpx # noqa: F401
2323

2424
HAS_HTTPX = True
2525
except ImportError:
2626
HAS_HTTPX = False
2727

2828
try:
29-
import requests
29+
import requests # noqa: F401
3030

3131
HAS_REQUESTS = True
3232
except ImportError:
@@ -359,7 +359,7 @@ def _get_session(self):
359359
verify_ssl=self.verify_ssl, proxy=self.proxy, force_new=True
360360
)
361361
elif HAS_REQUESTS:
362-
import requests
362+
import requests # noqa: F811
363363

364364
self._session = requests.Session()
365365
self._session.verify = self.verify_ssl

‎core/http/client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def request(
507507
from .exceptions import ConnectionError as HTTPConnectionError
508508

509509
raise HTTPConnectionError(
510-
f"熔断器已打开,目标 host 暂时不可用", url=url
510+
"熔断器已打开,目标 host 暂时不可用", url=url
511511
)
512512

513513
# 速率限制
@@ -682,7 +682,7 @@ async def async_request(
682682
from .exceptions import ConnectionError as HTTPConnectionError
683683

684684
raise HTTPConnectionError(
685-
f"熔断器已打开,目标 host 暂时不可用", url=url
685+
"熔断器已打开,目标 host 暂时不可用", url=url
686686
)
687687

688688
# 异步速率限制

‎core/knowledge/storage.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import uuid
1212
from collections import deque
1313
from pathlib import Path
14-
from typing import Any, Dict, List, Optional, Tuple
14+
from typing import Any
1515

1616
logger = logging.getLogger(__name__)
1717

‎core/post_exploit/advanced_techniques.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import base64
99
import logging
10+
import platform
1011
import random
1112
import string
1213
from dataclasses import dataclass, field

0 commit comments

Comments
 (0)