Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portscan tools #44

Merged
merged 6 commits into from
Mar 27, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
moved TCP connection open in a function
UlrichBerntien committed Mar 25, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6c2ba52e4be1ac46139dcec1fbf94852f328194a
21 changes: 19 additions & 2 deletions o.rc
Original file line number Diff line number Diff line change
@@ -53,6 +53,24 @@ sys.stdout.write(request.read())
fi
}

orc_tryTcpConnection () {
# Try to open a TCP connection to given host and port.
# Argument: host name or host IP address
# TCP port number
# Return: 0 if and ony if TCP connection could be opened
if [ $# -ne 2 ]; then
echo 'Error: need host and TCP port as arguments'
return 1
fi
if orc_existsProg bash; then
bash -c "echo '' > /dev/tcp/$1/$2" 2>/dev/null
else
echo 'Error: no tool to open TCP connection found'
return 1
fi
}


# ~~~ Helper Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# In the section of the internal helper functions are collected.
@@ -406,8 +424,7 @@ portscan() {
echo "Starting portscan of $1 ..."
for port in 21 22 23 80 443 8080 8443 129 445 3389 3306
do
bash -c "echo '' > /dev/tcp/$1/$port" 2>/dev/null
if echo $? | grep -q 0; then
if orc_tryTcpConnection "$1" "$port"; then
echo "Host $1 TCP port $port open"
fi
done