This repository has been archived by the owner on Aug 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
783 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,3 +112,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Pickle | ||
*.p/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
||
@dataclass | ||
class GTAIP: | ||
ipaddress : str | ||
firstseen : datetime | ||
lastseen : datetime | ||
country : str | ||
region : str | ||
city : str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import psutil, ctypes, sys, os, atexit | ||
from MainWindow import * | ||
|
||
def kill_proc_tree(): | ||
try: | ||
pid = os.getpid() | ||
|
||
firewall.delete_firewall_rule() | ||
parent = psutil.Process(pid) | ||
|
||
print('cleanup done') | ||
parent.kill() | ||
|
||
except: | ||
print("Something really went wrong") | ||
|
||
def is_admin(): | ||
try: return ctypes.windll.shell32.IsUserAnAdmin() | ||
except: return False | ||
|
||
def main(): | ||
if is_admin(): | ||
os.chdir(os.path.dirname(sys.argv[0])) | ||
app = MainWindow() | ||
app.mainloop() | ||
atexit.register(kill_proc_tree()) | ||
else: | ||
# Re-run the program with admin rights | ||
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) | ||
|
||
if __name__ == "__main__": | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import tkinter as tk | ||
from tkinter import ttk | ||
import webbrowser | ||
|
||
def callback(url): | ||
webbrowser.open_new_tab(url) | ||
|
||
def About(): | ||
win = tk.Toplevel() | ||
win.wm_title("About") | ||
|
||
tk.Label(win, text="About",font=("Arial", 25)).grid(row=0, column=0, padx=5, pady=2, columnspan=2, sticky='ew') | ||
|
||
tk.Label(win, text="Created by Aki [rarakat#3152]",font=("Arial", 12)).grid(row=1, column=0, padx=5, pady=2, columnspan=2, sticky='ew') | ||
|
||
tk.Label(win, text="GitHub:",font=("Arial", 12)).grid(row=3, column=0, sticky='w', padx=5,pady=5) | ||
githublbl = tk.Label(win, text=r"https://github.com/fscene8/GTAO_Session_Blocker", font=("Arial", 12), fg="blue", cursor="hand2") | ||
githublbl.grid(row=3, column=1, padx=5, pady=5, sticky='w') | ||
githublbl.bind("<Button-1>", lambda e: callback("https://github.com/fscene8/GTAO_Session_Blocker")) | ||
|
||
tk.Label(win, text="GTA Crew:",font=("Arial", 12)).grid(row=4, column=0, sticky='w', padx=5, pady=5) | ||
sclbl = tk.Label(win, text="https://socialclub.rockstargames.com/crew/sgpckias/", font=("Arial", 12), fg="blue", cursor="hand2") | ||
sclbl.grid(row=4, column=1, padx=5, pady=5, sticky='w') | ||
sclbl.bind("<Button-1>", lambda e: callback("https://socialclub.rockstargames.com/crew/sgpckias/")) | ||
|
||
b = ttk.Button(win, text="Okay", command=win.destroy) | ||
b.grid(row=5, column=0, columnspan=2, padx=5, pady=10, sticky='s') | ||
|
||
win.resizable(False, False) | ||
|
||
# Gets the requested values of the height and width. | ||
windowWidth = win.winfo_reqwidth() | ||
windowHeight = win.winfo_reqheight() | ||
|
||
# Gets both half the screen width/height and window width/height | ||
positionRight = int(win.winfo_screenwidth()/2 - windowWidth / 2) | ||
positionDown = int(win.winfo_screenheight()/2 - windowHeight/ 2) | ||
|
||
# Positions the window in the center of the page. | ||
win.geometry("+{}+{}".format(positionRight, positionDown)) | ||
|
||
|
||
def HowTo(): | ||
win = tk.Toplevel() | ||
win.wm_title("About") | ||
|
||
tk.Label(win, text="How to use",font=("Arial", 25)).grid(row=0, column=0, padx=5, pady=2, columnspan=2, sticky='ew') | ||
|
||
tk.Label(win, text="Step 1 > ",font=("Arial", 11)).grid(row=1, column=0, padx=5, pady=2, sticky='w') | ||
tk.Label(win, text="Run GTA Online", font=("Arial", 11)).grid(row=1, column=1, padx=5, pady=2, sticky='w') | ||
|
||
tk.Label(win, text="Step 2 > ",font=("Arial", 11)).grid(row=2, column=0, padx=5, pady=2, sticky='w') | ||
tk.Label(win, text="Suspend the process and be the session host", font=("Arial", 12)).grid(row=2, column=1, padx=5, pady=2, sticky='w') | ||
|
||
tk.Label(win, text="Step 3 > ",font=("Arial", 11)).grid(row=3, column=0, padx=5, pady=2, sticky='w') | ||
tk.Label(win, text="Invite your friend to your session and right click their IP to whitelist", font=("Arial", 11)).grid(row=3, column=1, padx=5, pady=2, sticky='w') | ||
|
||
tk.Label(win, text="Step 4 > ",font=("Arial", 11)).grid(row=4, column=0, padx=5, pady=2, sticky='w') | ||
tk.Label(win, text="Toggle on the firewall to prevent public from entering", font=("Arial", 11)).grid(row=4, column=1, padx=5, pady=2, sticky='w') | ||
|
||
tk.Label(win, text="Notes > ",font=("Arial", 11)).grid(row=5, column=0, padx=5, pady=2, sticky='w') | ||
tk.Label(win, text="You might need to toggle off your firewall for your friend to rejoin the session again", font=("Arial", 11)).grid(row=5, column=1, padx=5, pady=2, sticky='w') | ||
|
||
b = ttk.Button(win, text="Okay", command=win.destroy) | ||
b.grid(row=6, column=0, columnspan=2, padx=5, pady=2, sticky='s') | ||
|
||
win.resizable(False, False) | ||
|
||
# Gets the requested values of the height and width. | ||
windowWidth = win.winfo_reqwidth() | ||
windowHeight = win.winfo_reqheight() | ||
|
||
# Gets both half the screen width/height and window width/height | ||
positionRight = int(win.winfo_screenwidth()/2 - windowWidth / 2) | ||
positionDown = int(win.winfo_screenheight()/2 - windowHeight/ 2) | ||
|
||
# Positions the window in the center of the page. | ||
win.geometry("+{}+{}".format(positionRight, positionDown)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# GTAO Session Blocker | ||
My first python project with multithreading and subprocess with GUI tkinter. | ||
I had enough of grievers in game! | ||
|
||
### Features | ||
* Play Grand Theft Auto Online with friends only. | ||
* Detect other players IP in session, with more details (lastseen, location) | ||
* Whitelist IP addresses and play with your friends without modder/hackers | ||
* Auto saves and leave notes your whitelist IP list | ||
|
||
### Installation | ||
1. Install [npcap](https://nmap.org/npcap/) for packet sniffing | ||
2. Run `GTAO_Session_Blocker.exe` | ||
|
||
### How to use | ||
1. Run GTA Online | ||
2. Run `GTAO_Session_Blocker.exe` | ||
3. Load to a session, suspend GTA5 process and be the session host | ||
4. Invite your friend over to your session | ||
5. Whitelist their IP (right click the table below) | ||
6. Turn on firewall | ||
|
||
# Requirements | ||
|
||
### Drivers | ||
| Driver | Description | | ||
|----|---| | ||
| [npcap](https://nmap.org/npcap/) | Packet sniffing | | ||
|
||
### Modules | ||
|
||
| Module | Description | | ||
|-------------|------------------------------------------| | ||
| [tksheet](https://github.com/ragardner/tksheet) | Table widget for displaying tabular data | | ||
| [scapy](https://github.com/secdev/scapy) | Packet manipulation | | ||
| [ip2geotools](https://github.com/tomas-net/ip2geotools) | Geolocation information IP address | | ||
| [psutil](https://github.com/giampaolo/psutil) | Process and system monitoring in Python | | ||
|
||
### Special Thanks | ||
* @abdulmudhir for sharing [firewall.py](https://github.com/AbdulMudhir/GTA_V_Firewall_Public_Online/blob/master/firewall.py), which made this project possible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import socket | ||
from GTAIP import GTAIP | ||
from scapy.all import * | ||
from ip2geotools.databases.noncommercial import DbIpCity | ||
from datetime import datetime | ||
|
||
class SnifferThread(Thread): | ||
def __init__(self): | ||
# Call the Thread class's init function | ||
Thread.__init__(self) | ||
self.ipDictionary = {} | ||
|
||
def pc(self, packet): | ||
if packet.proto == 17: | ||
udp = packet.payload | ||
|
||
def stop(self): | ||
self.keeprunning = False | ||
|
||
def getlocalIPAddress(self) -> str: | ||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||
s.connect(("8.8.8.8", 80)) | ||
ip = s.getsockname()[0] | ||
s.close() | ||
return ip | ||
|
||
def clearIPDictionary(self): | ||
self.ipDictionary = {} | ||
|
||
def getIPDictionary(self): | ||
return self.ipDictionary | ||
|
||
def run(self) -> None: | ||
print('Sniffer thread spawned') | ||
|
||
self.keeprunning = True | ||
self.ipDictionary = {} | ||
localIP = self.getlocalIPAddress() | ||
while True: | ||
packet = sniff(filter="udp and port 6672", prn=self.pc, store=1, count=1) # GTA V Online UDP default Port is 6672 | ||
#y = x[0][IP].src | ||
dest = packet[0][IP].dst | ||
if dest == localIP: | ||
pass | ||
else: | ||
if not dest in self.ipDictionary.keys(): | ||
try: | ||
self.ipDictionary[dest] = GTAIP(dest,datetime.now(), datetime.now(), DbIpCity.get(dest, api_key='free').country, DbIpCity.get(dest, api_key='free').region, DbIpCity.get(dest, api_key='free').city) | ||
except: | ||
self.ipDictionary[dest] = GTAIP(dest,datetime.now(), datetime.now(), DbIpCity.get(dest, api_key='free').country, "Spoof", "IP") | ||
else: | ||
self.ipDictionary[dest].lastseen = datetime.now() |
Oops, something went wrong.