![]() |
| | #1 |
| Registered User Join Date: Nov 2006 Location: under your bed....
Posts: 24
| Port Scanner This is my first post, also i am new to c programming so if i make a mistake or if i've posted this in the wrong section or something please correct me ;P. So at tech today i was reading an online c manual and thought it would be pretty cool make to a half decent proggy. Here is what I wrote and i was wonder if someone could give me afew links or some explain source code to me on how port scanning works. Code: #include <iostream>
using namespace std;
int checkPort()
{
// Loop scans port 3 times
int i = 3;
while (i > 0){
// Scan port;
// record results in;
--i;
}
}
int main()
{
// Inputs port number
int iPort;
cout << "Enter port you want to scan: ";
cin >> iPort;
// Scans the port
checkPort();
// Prints result
cout << "Port Result: " << endl;
cout << "1. " << endl;
cout << "2. " << endl;
cout << "3. " << endl;
system("Pause");
return 0;
}
Cheers in advance. |
| Stabbsy is offline | |
| | #2 |
| * Death to Visual Basic * Join Date: Aug 2001
Posts: 768
| Well... If you're new to C, maybe you jumped a little too far ahead. - If you're planning to scan a remote machine for open ports, you will need to send packets. To send packets you will need to learn network programming, sockets; I suggest you read this document first: beej.us/guide/bgnet/output/print/bgnet_A4.pdf - Now to the interesting part, the scanning itself. Nmap, in my opinion is the best scanner on the network, it's open source and applies different simple and complex methods to scan a remote machine, read about them here: http://insecure.org/nmap/nmap_doc.html Please note, that for 90% of the methods you will need to go a lot deeper, and be able to construct your own raw packets: Raw socket/network programming. - I would also suggest you learn about networking, how the whole thing works. The structure of the TCP/IP, how the packet travels from one machine to another. What kind of devices are there on the network, what do they do with the packet, etc. - And one last thing, get yourself a good sniffer, I suggest Ethereal. You will thank me once you start working... Goodluck.
__________________ "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe http://www.Bloodware.net - Developing free software for the community. |
| Devil Panther is offline | |
| | #3 |
| Registered User Join Date: Dec 2002
Posts: 488
| it may intrest you to know that the code you posted is c++ and not c. |
| kryptkat is offline | |
| | #4 | |
| * Death to Visual Basic * Join Date: Aug 2001
Posts: 768
| Quote:
__________________ "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe http://www.Bloodware.net - Developing free software for the community. | |
| Devil Panther is offline | |
| | #5 |
| Registered User Join Date: Nov 2006 Location: under your bed....
Posts: 24
| Devil Panther thanks you alot for your reply. I have used WPE sniffer before due to my laziness in online games ^_^. ill read these link u gave to me and try to understand them . |
| Stabbsy is offline | |
| | #6 |
| * Death to Visual Basic * Join Date: Aug 2001
Posts: 768
| To tell you the truth, the material is not hard... But without any knowledge in Networking it might be a little difficult. BTW, here is a link to Raw Socket/Network Programming: http://www.madchat.org//coding/c/c.r...raw_socket.txt Anyway, good luck.
__________________ "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe http://www.Bloodware.net - Developing free software for the community. |
| Devil Panther is offline | |
| | #7 |
| geek Join Date: Aug 2005
Posts: 19
| hear a good book on network programming call: Unix network programming by W.Richard Stevens. |
| Whiteghost is offline | |
| | #8 |
| Mad Join Date: Jan 2005 Location: Umeå, Sweden
Posts: 555
| That's quite a strange piece of code as the inputted port number is never passed to the function responsible of scanning the port. Port scanning is pretty simple, connect to the remote adress at the specified port. Was the connection successful? If so then the port is open for business and you close the connection. Otherwise it's closed or an error occurred. To find out which check the error messages, a "Connection Refused" would mean that the port is closed. |
| OnionKnight is offline | |
| | #9 | |
| * Death to Visual Basic * Join Date: Aug 2001
Posts: 768
| Quote:
plus it's slow like hell.
__________________ "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe http://www.Bloodware.net - Developing free software for the community. | |
| Devil Panther is offline | |
| | #10 | |
| Cat without Hat Join Date: Apr 2003
Posts: 8,492
| Quote:
RIGHT?
__________________ All the buzzt! CornedBee"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code." - Flon's Law | |
| CornedBee is offline | |
| | #11 | |
| Just kidding.... Join Date: Jun 2003
Posts: 223
| Quote:
And, in insecure.org you can find information about port scanning. | |
| fnoyan is offline | |
| | #12 | |
| * Death to Visual Basic * Join Date: Aug 2001
Posts: 768
| Quote:
And it's here to teach us more, as you said... and as I said a few posts back. As for the Logging, if you really wish to test your own logging, then you'll be doing a horrible job because if you really believe that the people who want to attack your poor network are going to scan you with traditional methods then you have another thing coming. ENJOY!
__________________ "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe http://www.Bloodware.net - Developing free software for the community. | |
| Devil Panther is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A more advanced port scanner | fssp | C Programming | 6 | 03-23-2009 01:14 AM |
| FTP program | jakemott | Linux Programming | 14 | 10-06-2008 01:58 PM |
| My TCP Port Scanner in C | billy786 | Networking/Device Communication | 5 | 06-28-2008 07:12 PM |
| brace-enclosed error | jdc18 | C++ Programming | 53 | 05-03-2007 05:49 PM |
| Basic port scanner code .. pls help ??? | intruder | C Programming | 18 | 03-13-2003 08:47 AM |