This repository has been archived by the owner on Mar 2, 2022. It is now read-only.
forked from fullhunt/log4j-scan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix fullhunt#80 : Support custom TCP callback host
- Loading branch information
Showing
6 changed files
with
100 additions
and
9 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
*.py text eol=lf |
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
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
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 @@ | ||
# Simple Python TCP receiver | ||
|
||
Simple TCP receiver, which logs and writes in `output.txt` file any IP trying to connect on it (port 80, most common). | ||
|
||
It is for `--custom-tcp-callback-host` option usage of *log4j-scan*. | ||
|
||
Usage: | ||
|
||
```shell | ||
nohup python3 log4ShellReceiver.py 2>&1 & | ||
``` |
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,34 @@ | ||
import socket | ||
import sys | ||
|
||
# Create a socket | ||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
|
||
# Ensure that you can restart your server quickly when it terminates | ||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | ||
|
||
# Set the client socket's TCP "well-known port" number | ||
well_known_port = 80 | ||
sock.bind(('', well_known_port)) | ||
|
||
# Set the number of clients waiting for connection that can be queued | ||
print("Listening on " + str(well_known_port)) | ||
sock.listen(20) | ||
|
||
# loop waiting for connections (terminate with Ctrl-C) | ||
try: | ||
while 1: | ||
# accept | ||
newSocket, address = sock.accept() | ||
newSocket.setblocking(0) | ||
sys.stdout.write("Connected from %s:%d..." % address) | ||
|
||
# log the IP address | ||
with open("output.txt", "a") as outfile: | ||
outfile.write("%s\n" % address[0]) | ||
|
||
# close the connection quickly | ||
newSocket.close() | ||
print("disconnected") | ||
finally: | ||
sock.close() |
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