diff options
author | epochqwert <epoch@hacking.allowed.org> | 2015-05-03 06:31:59 -0500 |
---|---|---|
committer | epochqwert <epoch@hacking.allowed.org> | 2015-05-03 06:31:59 -0500 |
commit | 2b4697d313c0dfae862ee42d4bbc608e50c5eb22 (patch) | |
tree | 49a0b9412e760a66ed61683b7c8067ace78c5de0 /nocompile | |
parent | 9be8e4e8524a1d33390c8b8824a05ef5624e783e (diff) | |
download | misc-2b4697d313c0dfae862ee42d4bbc608e50c5eb22.tar.gz misc-2b4697d313c0dfae862ee42d4bbc608e50c5eb22.zip |
added a NetBSDian tcpident which doesn't even deal with real sockets so you can check any ports and IPs you want.
identd.sh uses tcpident and peerip and sockip programs to be a simple inetd runnable ident service.
Diffstat (limited to 'nocompile')
-rwxr-xr-x | nocompile/bin/identd.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nocompile/bin/identd.sh b/nocompile/bin/identd.sh new file mode 100755 index 0000000..67de244 --- /dev/null +++ b/nocompile/bin/identd.sh @@ -0,0 +1,17 @@ +#!/bin/sh +IPA="$(/usr/local/libexec/sockip | head -n1)" +IPB="$(/usr/local/libexec/peerip | head -n1)" +#read the ports from stdin to be looked up. +#in the format: PORT, PORT\r\n +read LINE +PB="$(printf "%s" "$LINE" | cut -d, -f1 | tr -cd "[0-9]")" +PA="$(printf "%s" "$LINE" | cut -d, -f2 | tr -cd "[0-9]")" +#example output: +#57132,6667:USERID:UNIX:segfault +#5132,6667:ERROR:NO-USER +USER="$(getent passwd "$(tcpident $IPA $PA $IPB $PB)" | cut -d: -f1)" +if [ "_$USER" != "_" ];then + printf "%s,%s:USERID:UNIX:%s\r\n" "$PB" "$PA" "$USER" +else + printf "%s,%s:ERROR:NO-USER\r\n" "$PB" "$PA" +fi |