telnet output save it to file using .bat file - windows

telnet 10.0.0.22 3389 ( for checking rdp port )
I want to create a batch file, for checking two or three port, so i create a .bat file in that i have written
telnet 10.0.0.22 1158 >> C:\result\telnetresult.txt
telnet 10.0.0.22 3389 >> C:\result\telnetresult.txt
telnet 10.0.0.22 1159 >> C:\result\telnetresult.txt
but it didn't work. Can you suggest where i am doing mistake or if there is some other alternative / Workaround.
I also tried to create another .bat file with the following command.
Telnet
set logfile c:\log.txt
Open 10.0.0.22 80
open 10.0.0.22 1158
open 10.0.0.22 3389
but it also didn't work.

You could try telnet “IP Address” -f “file location". Found the solution here.

try this:
for port in 1158 3389 1159
do
echo "telnet 10.0.0.22 $port"
echo $port |xargs telnet 10.0.0.22 >> C:\result\telnetresult.txt
done
some similar output
telnet 10.0.0.22 1158
Trying 10.0.0.22...
telnet: Unable to connect to remote host: Connection refused
telnet 10.0.0.22 3389
Trying 10.0.0.22...
telnet: Unable to connect to remote host: Connection refused
telnet 10.0.0.22 1159
Trying 10.0.0.22...
Connected to 10.0.0.22.
Escape character is '^]'.
Connection closed by foreign host.

Related

How can I upload a file via ssh to my server with a different port then 22?

I try to upload a file via ssh to my server:
scp -p 2222 user#myhost:/Users/myuser/mypage/myrepository.git
I get the error message:
ssh: connect to host myhost port 22: Connection refused
How do I specify scp to use port 2222?
scp uses an upper-case P to specify the port.
Try this instead:
scp -P 2222 user#myhost:/Users/myuser/mypage/myrepository.git
This worked for me:
scp -P 2222 -r myrepository.git user#myhost:/Users/myuser/mypage/

How do i verify that port 5555 is open?

I have a task in a lab for my cyber-security class where I have to verify that the port 5555 is open and not in use via Command Prompt. I have tried the following command with these flags:
command used to check port 5555
You can do a nmap scan on that port to see if its open or close; also you can get more information about the port if its open this way.
nmap -vvv <ip> -p 5555
if you are looking for a fast way you can try to connect to that port and see using netcat or telnet
nc localhost 5555
telnet localhost 5555
if the port is close your connection will drop if its open the connection wont close if the application running on port 5555 has a header you can also see that.
in case you looking for open ports in your own computer you can do ss -lnpt which will show all open ports. then you can grep for port 5555
You can either use netstat or sudo lsof -i tcp:5555.
If you don't get a response on your terminal, it means that there's nothing running on port 5555.

rsync and torsocks error: connection refused (111) and error in socket IO (code 10)

I wanted to download some files from tor (.onion site) with rsync and torsocks with this command (I'm on Linux):
torsocks rsync rsync://root#snatchvwddns6zto.onion/targets/perceptics.com/
and it returns back the error:
1560930992 PERROR torsocks[13894]: socks5 libc connect: Connection refused (in socks5_connect() at socks5.c:202)
rsync: failed to connect to snatchvwddns6zto.onion (127.42.42.0): Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(127) [Receiver=3.1.3]
And the onion site snatchvwddns6zto.onion/targets/perceptics.com/ is fully functional
Already changed the port of the torsocks.conf file to the same port that tor is already on (9051) and still didn't work.
Even when trying to authenticate:
echo -e 'AUTHENTICATE "passwordhere"\r\nsignal NEWNYM\r\nQUIT' | nc 127.0.0.1 9051
it returns:
(UNKNOWN) [127.0.0.1] 9051 (?) : Connection refused
torsocks.conf:
TorAddress 127.0.0.1
TorPort 9150
Does someone know how to solve does errors?
You can also expose the SSH port instead of the rsync one and do something like:
torify rsync -e "ssh -p 9051" root#snatchvwddns6zto.onion:targets/perceptics.com/ ./

netcat windows listen for password on UDP

I want to use netcat to open a listener on an UDP port using netcat (any other tool is welcome as well, but it's the one I have found to be useful for now), which is listening for a password to be entered to execute another action.
Here is what I have so far, but it doesn't work as desired:
ncat.exe -kluvp 4444 -c "set /P pwd=pwd: & if %pwd%==pwd (echo yes) else (echo no)
But when I connect from the client, ncat -4u -w1 localhost 4444, with whatever I write as input I get yes, but it should only print yes when I write pwd.

ftp is not resolving hostname from hosts file

I have hostname in /etc/hosts,
10.0.0.124 hostname.domain hostname
I can ping and ssh to hostname. When I enter
ftp 10.0.0.124
or
ftp hostname
I get "No route to host" in response. When I comment out that line, and try
ftp hostname
ftp responds "Name or service not known". So ftp is looking in the hosts file but apparently does not believe it. Why not?? I am on CentOS 6.5 and ftp was installed using yum install ftp. The ftp daemon running on hostname is vsftpd.
And fixed! The problem was that hostname's firewall was configured to drop ftp packets. Obvious! Inserted
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
in /etc/sysconfig/iptables, and restarted iptables service. Done!

Resources