add iw took for recon

This commit is contained in:
David Westgate 2024-05-22 21:48:40 -07:00
parent f41a632da1
commit e6ef898467
3 changed files with 40 additions and 13 deletions

View File

@ -15,8 +15,7 @@ from langchain.tools import tool
from tools import (
get_wireless_interface,
change_adapter_mode,
wifi_encryption_cracking,
packet_capture_reconnaissance,
wifi_network_reconnissance,
wifi_encryption_cracking,
packet_frame_transmission,
)
@ -37,8 +36,7 @@ tools.extend(
[
get_wireless_interface,
change_adapter_mode,
wifi_encryption_cracking,
packet_capture_reconnaissance,
wifi_network_reconnissance,
wifi_encryption_cracking,
packet_frame_transmission,
]
@ -69,7 +67,7 @@ for tool in tools:
while True:
line = input("llm>> ")
if line:
result: Dict[str, any] = agent_executor.invoke({"input": line})
result = agent_executor.invoke({"input": line})
print(result["output"])
else:
break

10
hw6/requirements.txt Normal file
View File

@ -0,0 +1,10 @@
langchain==0.2.0
langchain_community==0.2.0
langchain_core==0.2.1
langchain_openai==0.1.7
python-dotenv==1.0.1
Requests==2.32.2
langchain-experimental
langchainhub

View File

@ -70,19 +70,38 @@ def packet_frame_transmission(params: str) -> str:
return res
class PacketCapture(BaseModel):
params: str = Field(
description="Should be command line parameters to 'airodump-ng' to perform some kind of wifi reconnaissance or packet capture"
# class PacketCapture(BaseModel):
# params: str = Field(
# description="Should be command line parameters to 'airodump-ng' to perform some kind of wifi reconnaissance or packet capture"
# )
# @tool(
# "Perform packet capture or wifi reconnaissance with airodump-ng",
# args_schema=PacketCapture,
# return_direct=False,
# )
# def packet_capture_reconnaissance(params: str) -> str:
# """Can pass parameters to airodump-ng to perform packet capture or wifi reconnaissance"""
# res = shell_tool.run({"commands": [f"sudo timeout 15s airodump-ng {params}"]})
# return res
class IwScan(BaseModel):
interface: str = Field(
description="Should be a wireless interface name, used as a paramater to 'iw' to scan for wifi networks"
)
network: str = Field(
description="Should be the name or SSID of the wifi network you are interested in"
)
@tool(
"Perform packet capture or wifi reconnaissance with airodump-ng",
args_schema=PacketCapture,
"Perform wifi scanning with iw",
args_schema=IwScan,
return_direct=False,
)
def packet_capture_reconnaissance(params: str) -> str:
"""Can pass parameters to airodump-ng to perform packet capture or wifi reconnaissance"""
res = shell_tool.run({"commands": [f"sudo timeout -s SIGINT 15s airodump-ng {params}"]})
def wifi_network_reconnissance(interface: str, network: str) -> str:
"""Can pass a wireless interface name and wifi network name to return technical information about a wifi network"""
res = shell_tool.run({"commands": [f'sudo iw {interface} scan | grep -B 9 -A 206 "{network}"']})
return res