From 44f255512aa201440c7b1facad1048c340f0a7e1 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:08:39 +0000 Subject: [PATCH 01/18] fix dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 278c9a6..4e14a2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,7 @@ WORKDIR /usr/src/app COPY ./requirements.txt . RUN apt update RUN apt install nmap -y -RUN pip install --no-cache-dir -r requirements.txt -vvv +RUN apt install -y python3 python3-pip +RUN pip3 install --no-cache-dir -r requirements.txt -vvv CMD [ "python", "./garfbot.py" ] From 68008771d0863fb985bbe170c2727e8c0a1e4534 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:10:44 +0000 Subject: [PATCH 02/18] dockerfile --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4e14a2a..aaa2b27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,10 @@ COPY ./requirements.txt . RUN apt update RUN apt install nmap -y RUN apt install -y python3 python3-pip -RUN pip3 install --no-cache-dir -r requirements.txt -vvv +# RUN pip3 install --no-cache-dir -r requirements.txt -vvv +RUN pip3 install discord +RUN pip3 install openai +RUN pip3 install aiohttp +RUN pip3 install requests CMD [ "python", "./garfbot.py" ] From 090c8eebda433eaf905c70bc9b4d81d2754e6afa Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:13:52 +0000 Subject: [PATCH 03/18] dockerfile rust --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index aaa2b27..f98864c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,10 @@ WORKDIR /usr/src/app COPY ./requirements.txt . RUN apt update -RUN apt install nmap -y -RUN apt install -y python3 python3-pip +RUN apt install -y nmap +RUN apt install -y rust +RUN apt install -y python3 +RUN apt install -y python3-pip # RUN pip3 install --no-cache-dir -r requirements.txt -vvv RUN pip3 install discord RUN pip3 install openai From 18bf19ee3d8d083ec7a7e12262a483dc2b535265 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:14:21 +0000 Subject: [PATCH 04/18] dockerfile rust --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f98864c..6a968da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /usr/src/app COPY ./requirements.txt . RUN apt update RUN apt install -y nmap -RUN apt install -y rust +RUN apt install -y rustc RUN apt install -y python3 RUN apt install -y python3-pip # RUN pip3 install --no-cache-dir -r requirements.txt -vvv From dfac5753a1528ca8e0180057cf585070e29c741d Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:17:10 +0000 Subject: [PATCH 05/18] dockerfile python version --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6a968da..ad21a80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM python:3.13.0rc2-bookworm +FROM python:3.11-bookworm⁠ WORKDIR /usr/src/app COPY ./requirements.txt . RUN apt update RUN apt install -y nmap -RUN apt install -y rustc +# RUN apt install -y rustc RUN apt install -y python3 RUN apt install -y python3-pip # RUN pip3 install --no-cache-dir -r requirements.txt -vvv From c5f07792e90bf5a17a3b2c83c953e3a3d10cfc3d Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:17:39 +0000 Subject: [PATCH 06/18] dockerfile python version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ad21a80..20dc370 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11-bookworm⁠ +FROM python:3.11.10-bookworm⁠ WORKDIR /usr/src/app From 353198e6f4c35d5a0861ad1247ee7133878d4dae Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:21:46 +0000 Subject: [PATCH 07/18] fix bookworm --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 20dc370..a044c65 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11.10-bookworm⁠ +FROM python:3.11.10-bookworm WORKDIR /usr/src/app From 56d8ff929df7abe69a140d9b30bdd581984bf0be Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:25:22 +0000 Subject: [PATCH 08/18] fix dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a044c65..93d5423 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,11 +4,11 @@ WORKDIR /usr/src/app COPY ./requirements.txt . RUN apt update +RUN apt install -y iputils-ping +RUN apt install -y dnsutils RUN apt install -y nmap -# RUN apt install -y rustc RUN apt install -y python3 RUN apt install -y python3-pip -# RUN pip3 install --no-cache-dir -r requirements.txt -vvv RUN pip3 install discord RUN pip3 install openai RUN pip3 install aiohttp From 33657d8947e86006dec4f8e4382420a2024eefc1 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:27:02 +0000 Subject: [PATCH 09/18] add garfbot.sh --- garfbot.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 garfbot.sh diff --git a/garfbot.sh b/garfbot.sh new file mode 100644 index 0000000..7eaaf52 --- /dev/null +++ b/garfbot.sh @@ -0,0 +1 @@ +docker run -d --restart always -v $PWD:/usr/src/app --name garfbot garfbot \ No newline at end of file From 3302326f1b13bcb7f20fb02e8b90db5a3b45c6ea Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:42:30 +0000 Subject: [PATCH 10/18] reject private networks test --- garfbot.py | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/garfbot.py b/garfbot.py index cc46273..e02eae5 100644 --- a/garfbot.py +++ b/garfbot.py @@ -49,6 +49,18 @@ intents.message_content = True garfbot = discord.Client(intents=intents) +# Network Utils Setup +def is_private(target): + try: + ip_obj = ipaddress.ip_address(target) + if ip_obj.is_private: + return True + except ValueError: + if "crate.lan" in target.lower(): + return True + return False + + # Kroger Setup client_id = config.CLIENT_ID client_secret = config.CLIENT_SECRET @@ -225,11 +237,32 @@ async def on_message(message): try: query = message.content.split() target = query[-1] - result = subprocess.run(['ping', '-c', '1', target], capture_output=True, text=True) - await message.channel.send(f"`Ping result for {target}: {result.stdout}`") + if is_private(target): + rejection = await generate_chat_response("Hey Garfield, I am hacking your computer network.") + else: + result = subprocess.run(['ping', '-c', '4', target], capture_output=True, text=True) + await message.channel.send(f"`Ping result for {target}: {result.stdout}`") except Exception as e: await message.channel.send(f"`GarfBot Error: {str(e)}`") + # if message.content.lower().startswith("garfdns "): + # try: + # query = message.content.split() + # target = query[-1] + # result = subprocess.run(['nslookup', target], capture_output=True, text=True) + # await message.channel.send(f"`Ping result for {target}: {result.stdout}`") + # except Exception as e: + # await message.channel.send(f"`GarfBot Error: {str(e)}`") + + # if message.content.lower().startswith("garfhack "): + # try: + # query = message.content.split() + # target = query[-1] + # result = subprocess.run(['ping', '-c', '1', target], capture_output=True, text=True) + # await message.channel.send(f"`Ping result for {target}: {result.stdout}`") + # except Exception as e: + # await message.channel.send(f"`GarfBot Error: {str(e)}`") + # Kroger Shopping if message.content.lower().startswith("garfshop "): try: From c4f2eedaf8f758db2108675d8b28f31c14d3ea74 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:44:40 +0000 Subject: [PATCH 11/18] import ipaddress --- garfbot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/garfbot.py b/garfbot.py index e02eae5..627852c 100644 --- a/garfbot.py +++ b/garfbot.py @@ -8,6 +8,7 @@ import aiohttp import asyncio import discord import requests +import ipaddress import subprocess from base64 import b64encode from openai import AsyncOpenAI From 2c6bbf1b64266272e981933eb1c26ec06bc3bc96 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:47:21 +0000 Subject: [PATCH 12/18] fix rejection --- garfbot.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/garfbot.py b/garfbot.py index 627852c..72ec7fd 100644 --- a/garfbot.py +++ b/garfbot.py @@ -240,29 +240,14 @@ async def on_message(message): target = query[-1] if is_private(target): rejection = await generate_chat_response("Hey Garfield, I am hacking your computer network.") + await message.channel.send(rejection) else: result = subprocess.run(['ping', '-c', '4', target], capture_output=True, text=True) await message.channel.send(f"`Ping result for {target}: {result.stdout}`") except Exception as e: await message.channel.send(f"`GarfBot Error: {str(e)}`") - # if message.content.lower().startswith("garfdns "): - # try: - # query = message.content.split() - # target = query[-1] - # result = subprocess.run(['nslookup', target], capture_output=True, text=True) - # await message.channel.send(f"`Ping result for {target}: {result.stdout}`") - # except Exception as e: - # await message.channel.send(f"`GarfBot Error: {str(e)}`") - # if message.content.lower().startswith("garfhack "): - # try: - # query = message.content.split() - # target = query[-1] - # result = subprocess.run(['ping', '-c', '1', target], capture_output=True, text=True) - # await message.channel.send(f"`Ping result for {target}: {result.stdout}`") - # except Exception as e: - # await message.channel.send(f"`GarfBot Error: {str(e)}`") # Kroger Shopping if message.content.lower().startswith("garfshop "): From b8e09c04ffd1d50360e81e26b3ebc5718d9d60ef Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:50:08 +0000 Subject: [PATCH 13/18] add nslookup --- garfbot.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/garfbot.py b/garfbot.py index 72ec7fd..5e5678b 100644 --- a/garfbot.py +++ b/garfbot.py @@ -239,7 +239,7 @@ async def on_message(message): query = message.content.split() target = query[-1] if is_private(target): - rejection = await generate_chat_response("Hey Garfield, I am hacking your computer network.") + rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") await message.channel.send(rejection) else: result = subprocess.run(['ping', '-c', '4', target], capture_output=True, text=True) @@ -247,7 +247,18 @@ async def on_message(message): except Exception as e: await message.channel.send(f"`GarfBot Error: {str(e)}`") - + if message.content.lower().startswith("garfdns "): + try: + query = message.content.split() + target = query[-1] + if is_private(target): + rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") + await message.channel.send(rejection) + else: + result = subprocess.run(['nslookup', target], capture_output=True, text=True) + await message.channel.send(f"`NSLookup result for {target}: {result.stdout}`") + except Exception as e: + await message.channel.send(f"`GarfBot Error: {str(e)}`") # Kroger Shopping if message.content.lower().startswith("garfshop "): From 6896fca5a0bc6cbe4ae82ca12737d814bcbb42c3 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:53:41 +0000 Subject: [PATCH 14/18] add network utils print --- garfbot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/garfbot.py b/garfbot.py index 5e5678b..9042624 100644 --- a/garfbot.py +++ b/garfbot.py @@ -238,6 +238,7 @@ async def on_message(message): try: query = message.content.split() target = query[-1] + print(f"Ping Request - User: {user}, Server: {server}, Target: {target}", flush=True) if is_private(target): rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") await message.channel.send(rejection) @@ -251,6 +252,7 @@ async def on_message(message): try: query = message.content.split() target = query[-1] + print(f"NSLookup Request - User: {user}, Server: {server}, Target: {target}", flush=True) if is_private(target): rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") await message.channel.send(rejection) From c27a041ea3133545e50d82b5b7a2e40470db8148 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:55:35 +0000 Subject: [PATCH 15/18] fix netutils print --- garfbot.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/garfbot.py b/garfbot.py index 9042624..08e6033 100644 --- a/garfbot.py +++ b/garfbot.py @@ -237,6 +237,8 @@ async def on_message(message): if message.content.lower().startswith("garfping "): try: query = message.content.split() + user = message.author.name + server = message.guild.name if message.guild else "Direct Message" target = query[-1] print(f"Ping Request - User: {user}, Server: {server}, Target: {target}", flush=True) if is_private(target): @@ -251,6 +253,8 @@ async def on_message(message): if message.content.lower().startswith("garfdns "): try: query = message.content.split() + user = message.author.name + server = message.guild.name if message.guild else "Direct Message" target = query[-1] print(f"NSLookup Request - User: {user}, Server: {server}, Target: {target}", flush=True) if is_private(target): From f6c78e26d0e0d17a5ec63204aaa3316276af5827 Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 20:58:08 +0000 Subject: [PATCH 16/18] add nmap --- garfbot.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/garfbot.py b/garfbot.py index 08e6033..05530c5 100644 --- a/garfbot.py +++ b/garfbot.py @@ -266,6 +266,22 @@ async def on_message(message): except Exception as e: await message.channel.send(f"`GarfBot Error: {str(e)}`") + if message.content.lower().startswith("garfhack "): + try: + query = message.content.split() + user = message.author.name + server = message.guild.name if message.guild else "Direct Message" + target = query[-1] + print(f"Nmap Request - User: {user}, Server: {server}, Target: {target}", flush=True) + if is_private(target): + rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") + await message.channel.send(rejection) + else: + result = subprocess.run(['nmap', '-A', '-Pn', target], capture_output=True, text=True) + await message.channel.send(f"`Ping result for {target}: {result.stdout}`") + except Exception as e: + await message.channel.send(f"`GarfBot Error: {str(e)}`") + # Kroger Shopping if message.content.lower().startswith("garfshop "): try: From a25430cd17d0002ecb1804b300cc9badf7e6e76f Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 21:01:21 +0000 Subject: [PATCH 17/18] edit nmap --- garfbot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/garfbot.py b/garfbot.py index 05530c5..b8baafe 100644 --- a/garfbot.py +++ b/garfbot.py @@ -277,6 +277,7 @@ async def on_message(message): rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") await message.channel.send(rejection) else: + await message.channel.send(f"Scanning {target}, hold on a sec...") result = subprocess.run(['nmap', '-A', '-Pn', target], capture_output=True, text=True) await message.channel.send(f"`Ping result for {target}: {result.stdout}`") except Exception as e: From 25bd35db7e31968f12692bf05a2bac805fa4ad3f Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 30 Sep 2024 21:15:09 +0000 Subject: [PATCH 18/18] fix nmap --- garfbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/garfbot.py b/garfbot.py index b8baafe..757d909 100644 --- a/garfbot.py +++ b/garfbot.py @@ -277,8 +277,8 @@ async def on_message(message): rejection = await generate_chat_response("Hey Garfield, explain to me why I am dumb for trying to hack your private computer network.") await message.channel.send(rejection) else: - await message.channel.send(f"Scanning {target}, hold on a sec...") - result = subprocess.run(['nmap', '-A', '-Pn', target], capture_output=True, text=True) + await message.channel.send(f"`Scanning {target}...`") + result = subprocess.run(['nmap', '-Pn', '-O', '-v', target], capture_output=True, text=True) await message.channel.send(f"`Ping result for {target}: {result.stdout}`") except Exception as e: await message.channel.send(f"`GarfBot Error: {str(e)}`")