diff --git a/hw6/app.py b/hw6/app.py index ea49d3b..0b8a7ed 100644 --- a/hw6/app.py +++ b/hw6/app.py @@ -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 diff --git a/hw6/requirements.txt b/hw6/requirements.txt new file mode 100644 index 0000000..261e905 --- /dev/null +++ b/hw6/requirements.txt @@ -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 + + diff --git a/hw6/tools.py b/hw6/tools.py index ebcfb6a..2449a90 100644 --- a/hw6/tools.py +++ b/hw6/tools.py @@ -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