IP list specific port checker script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting IP list specific port checker script
# 1  
Old 02-28-2016
IP list specific port checker script

Hello again people,

I currently searching for a code/script that will allow it to check if a specific port is open, lets say 123. Found a public script on a ftp but I dont know how and what to modify in it to suit my needs. (I think this is a evil code and I want to use it as an example).

Code:
cat $1 | while read LN; do
SRV=`echo $LN | awk '{print $1}'`
php connect.php $SRV 123
done

And the file connect.php
Code:
<?php

function S_Server($_server, $_port, $_user, $_pass) {
        if ( "$_port" == "123" ) {
                print "[+]Found $_server\r\n";
                if(!($_OutFile = fopen("iplist", "a"))) ExitF ("Cannot open the log file");
                fputs($_OutFile, "$_server $_user $_pass\n");
                fclose($_OutFile);
        }

}

function ExitF($errmsg) {
        print "[-]" . $errmsg . "\r\n";
        exit(0);
}

function CrackSMTP($server, $port, $user, $pass) {
        $socket = fsockopen($server, $port, $errno, $errstr, 2);

        if (!$socket) ExitF ("SOCKET ERROR!");

        fclose($socket);

        S_Server ($server, $port, $user, $pass);

        exit(0);
}

if ($argv[4]) $_PASS = $argv[4];
if (!($_PASS)) $_PASS = "";

if (!($argv[3])) {
        ExitF ("Usage: $argv[0] <hostname> <port> <user> [password]");
}

else {
        CrackSMTP($argv[1], $argv[2], $argv[3], $argv[4]);
}

exit(0);
?>

If the port is open on the specific host to save it in a new file. Also my ip file is line-by-line.

Thank you again.

Galford D. Weller
# 2  
Old 02-28-2016
Did you consider the nc (netcat) tool with its port scanning capabilities?
man nc:
Quote:
PORT SCANNING
It may be useful to know which ports are open and running services on a target machine. The -z flag can be used to tell nc to report open ports, rather than initiate a connection. Usually it's useful to turn on verbose output to stderr by use this option in conjunction with -v option.
# 3  
Old 02-28-2016
I really wanna use that code as I found it useful and its almost done... but I dont know what to remove from it to suit my needs. I know this is not a coding service and I am willing to show my support and donate a fee... lets say 10$ via PayPal.
# 4  
Old 02-28-2016
This file follow the rules "Don't put all eggs in one basket" Smilie
Is part of a script to bruteforce scan/"crack" an SMTP server but the function called CrackSMTP() is not in the file Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed with File Checker Korn Shell Script

I am attempting to write a korn shell script that does the following, but I am getting errors. I'm new to korn shell scripting and am not sure what I am doing wrong. Please help with example scripts. Thanks. 1) check for day of the week 2) if day of the week is Monday then check for the... (4 Replies)
Discussion started by: ijmoore
4 Replies

2. UNIX for Beginners Questions & Answers

Bash script, find the next closed (not in use) port from some port range.

hi, i would like to create a bash script that check which port in my Linux server are closed (not in use) from a specific range, port range (3000-3010). the print output need to be only 1 port, and it will be nice if the output will be saved as a variable or in same file. my code is: ... (2 Replies)
Discussion started by: yossi
2 Replies

3. UNIX for Beginners Questions & Answers

Non-root script used search and list specific key words

Hy there all. Im new here. Olso new to terminal & bash, but it seams that for me it's much easyer to undarsatnd scripts than an actual programming language as c or anyother languare for that matter. S-o here is one og my home works s-o to speak. Write a shell script which: -only works as a... (1 Reply)
Discussion started by: Crisso2Face
1 Replies

4. Shell Programming and Scripting

Help with Bash Shell Script Spell Checker program.

I have a majority of this problem done but seem to be struggling on the last couple of steps. Here is the whole problem to help you guys get a better understanding. Write a shell script that implements a simple spell checker. The filename you will use for your script will be your Z-id followed... (1 Reply)
Discussion started by: DsmRacer2k14
1 Replies

5. Shell Programming and Scripting

How to make a script that logs bandwidth on a specific port?

I have a script that runs right before a daily reboot that captures the amount of MB transmitted up and pulled down since last reboot. echo `date +"%m-%d-%y"``grep eth0 /proc/net/dev | awk '{print ","$2/1024/1024","$10/1024/1024}'`>>/home/nick/bandwidth.logIn looking at the raw output of... (1 Reply)
Discussion started by: nbsparks
1 Replies

6. Homework & Coursework Questions

spell checker script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: When "niuspell" is invoked from the command line it reads "file" and checks it for spelling of the words it... (1 Reply)
Discussion started by: Jeffthrow5
1 Replies

7. Shell Programming and Scripting

Shell script or command help to extract specific contents from a long list of content

Hi, I got a long list of contents: >sequence_1 ASSSSSSSSSSSDDDDDDDDDDDCCCCCCC ASDSFDFFDFDFFWERERERERFSDFESFSFD >sequence_2 ASDFDFDFFDDFFDFDSFDSFDFSDFSDFDSFASDSADSADASD ASDFFDFDFASFASFASFAFSFFSDASFASFASFAFS >sequence_3 VEDFGSDGSDGSDGSDGSDGSDGSDG dDFSDFSDFSDFSDFSDFSDFSDFSDF... (2 Replies)
Discussion started by: patrick87
2 Replies

8. Solaris

how to open a specific port

Hi All, Can anyone let me know that how to open a specific port in Solaris 10. I just wanted to know if there are some certain commands to open a port (like ftp, telnet). It would be also better if someone can tell me if there is another firewall service in Solaris 10 except ipfilter. ... (6 Replies)
Discussion started by: naw_deepak
6 Replies

9. Solaris

how to open specific port

Dear members, My release is open Solaris b103 1- How to know the opening port in my system 2- How to open a specific port like port number 53 3- How to closed the specific port like port number 53 Your feedback highly appreciated (10 Replies)
Discussion started by: dellroxy
10 Replies

10. Shell Programming and Scripting

Shell script syntax checker

I have a rather big script that i have written in ksh and it is falling over in two places with a 'test argument' error. I know this usually means that the if statement is not correct, but it is fine. I have looked through the rest of the script for any odd brackets or ` marks, but can't see... (2 Replies)
Discussion started by: handak9
2 Replies
Login or Register to Ask a Question