<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Port scannen?]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich möchte mir einen Portscanner schreiben, jedoch verzweifel ich an der Hauptsache - nämlich dem Prüfen ob ein Port geöffnet ist.</p>
<p>Ich wollte dafür die IDICMP Komponente benutzen und dort dann den Port eingeben, jedoch scheint dies keine Auswirkung zu haben.</p>
<p>Zweite Idee war, dass ich mit dem ClientSocket auf den geöffneten Port verbinde und bei einem OK is der Port offen, sonst halt nicht.</p>
<p>Jedoch weiß ich nicht wie ich die Abfrage dafür machen kann...</p>
<p>Bei OnConnect sagt der Client immer er währe verbunden, Error o.ä. passiert nichts. Auch bei Disconnect nicht (obwohl es den Zielrechner 100% nicht gibt...)</p>
<pre><code>ClientSocket1-&gt;Active = true;
ClientSocket1-&gt;Open();
ClientSocket1-&gt;Socket-&gt;Connect(0);
</code></pre>
<p>Die einzelnen Events haben jeweils 'Form1-&gt;Caption = &quot;Verbunden&quot;' - bloß halt für jedes Event unterschiedlich.</p>
<p>Wie kann ich nun prüfen ob der Port offen ist oder nicht?</p>
<p>MfG:<br />
anonymous</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/93334/port-scannen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 09:59:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/93334.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 Nov 2004 18:08:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Port scannen? on Sun, 28 Nov 2004 18:08:06 GMT]]></title><description><![CDATA[<p>Hallo zusammen,<br />
ich möchte mir einen Portscanner schreiben, jedoch verzweifel ich an der Hauptsache - nämlich dem Prüfen ob ein Port geöffnet ist.</p>
<p>Ich wollte dafür die IDICMP Komponente benutzen und dort dann den Port eingeben, jedoch scheint dies keine Auswirkung zu haben.</p>
<p>Zweite Idee war, dass ich mit dem ClientSocket auf den geöffneten Port verbinde und bei einem OK is der Port offen, sonst halt nicht.</p>
<p>Jedoch weiß ich nicht wie ich die Abfrage dafür machen kann...</p>
<p>Bei OnConnect sagt der Client immer er währe verbunden, Error o.ä. passiert nichts. Auch bei Disconnect nicht (obwohl es den Zielrechner 100% nicht gibt...)</p>
<pre><code>ClientSocket1-&gt;Active = true;
ClientSocket1-&gt;Open();
ClientSocket1-&gt;Socket-&gt;Connect(0);
</code></pre>
<p>Die einzelnen Events haben jeweils 'Form1-&gt;Caption = &quot;Verbunden&quot;' - bloß halt für jedes Event unterschiedlich.</p>
<p>Wie kann ich nun prüfen ob der Port offen ist oder nicht?</p>
<p>MfG:<br />
anonymous</p>
]]></description><link>https://www.c-plusplus.net/forum/post/661279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/661279</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Sun, 28 Nov 2004 18:08:06 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Mon, 29 Nov 2004 16:40:57 GMT]]></title><description><![CDATA[<p>OK, ich habs soweit geschaft. (Tutorial von C-Workers)</p>
<p>Andere Frage dazu: Wie kann ich das Timeout für die Verbindungserstellung umstellen? Weil die Zeit ist mir zulange, es geht um's LAN, da brauch ich nur ein paarhundert MS</p>
<p>MfG:<br />
anonymous2k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/662053</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/662053</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Mon, 29 Nov 2004 16:40:57 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Thu, 02 Dec 2004 22:28:10 GMT]]></title><description><![CDATA[<p>Weißde keiner Rat?</p>
<p>anonymous2k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/664837</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/664837</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Thu, 02 Dec 2004 22:28:10 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Fri, 03 Dec 2004 05:25:52 GMT]]></title><description><![CDATA[<p>schreib doch erstmal wie du es geschafft hast. Evtl. kann dir dann jemand weiterhelfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/664876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/664876</guid><dc:creator><![CDATA[Acidmrp]]></dc:creator><pubDate>Fri, 03 Dec 2004 05:25:52 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Sat, 04 Dec 2004 10:53:10 GMT]]></title><description><![CDATA[<p>OK,<br />
ich habe winsock2.h includiert.</p>
<p>Dann mit diesem Code</p>
<pre><code>int startWinsock(void)
{
  WSADATA wsa;
  return WSAStartup(MAKEWORD(2,0),&amp;wsa);
}

int ScanPort(String IP, int Port)
{
  long rc;
  SOCKET s;

  SOCKADDR_IN addr;
  rc=startWinsock();
  if(rc!=0)
  {
    return 1;
  }

s=socket(AF_INET,SOCK_STREAM,0);
if(s==INVALID_SOCKET)
{
  return 1;
}

  memset(&amp;addr,0,sizeof(SOCKADDR_IN));
addr.sin_family=AF_INET;
addr.sin_port=htons(Port); // Port der üergeben wurde
addr.sin_addr.s_addr=inet_addr(IP.c_str()); //Das zu scannende IP

rc=connect(s,(SOCKADDR*)&amp;addr,sizeof(SOCKADDR));

if(rc==SOCKET_ERROR)
{
  return 1;
}
else
{
  closesocket(Port);
  return 0;
}
}
</code></pre>
<p>Der Code funzt auch, aber leider dauert das Timeout zulange. (3 Sek ungefähr)</p>
<p>Mit einem Registrywert konnte ich das Wiederholen bei Timeout schonmal ausstellen, aber es müsste ja eigendlich eine Möglichkeit geben Timeout auch auf 200ms zu setzen.</p>
<p>Jemand Ideen?</p>
<p>anonymous2k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665632</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665632</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Sat, 04 Dec 2004 10:53:10 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Sat, 04 Dec 2004 11:00:16 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=437" rel="nofollow">Jansen</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=2" rel="nofollow">Borland C++ Builder (VCL/CLX)</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/665638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665638</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sat, 04 Dec 2004 11:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Sat, 04 Dec 2004 12:06:42 GMT]]></title><description><![CDATA[<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/setsockopt_2.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/setsockopt_2.asp</a><br />
würd ich jetz ma auf anhieb sagen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665685</guid><dc:creator><![CDATA[jghj]]></dc:creator><pubDate>Sat, 04 Dec 2004 12:06:42 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Sat, 04 Dec 2004 16:58:53 GMT]]></title><description><![CDATA[<p>Also, ich habe jetzt mal das setsockopt Beispiel kopiert und auf den Timeoutcode angepasst (nur den KEEPALIVE teil mit Timeout gewechselt)</p>
<pre><code>#include &lt;stdio.h&gt;
#include &quot;winsock2.h&quot;

void main() {

  //---------------------------------------
  // Declare variables
  WSADATA wsaData;
  SOCKET ListenSocket;
  sockaddr_in service;

  //---------------------------------------
  // Initialize Winsock
  int iResult = WSAStartup( MAKEWORD(2,2), &amp;wsaData );
  if( iResult != NO_ERROR )
    printf(&quot;Error at WSAStartup\n&quot;);

  //---------------------------------------
  // Create a listening socket
  ListenSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP );
  if (ListenSocket == INVALID_SOCKET) {
    printf(&quot;Error at socket()\n&quot;);
    WSACleanup();
    return;
  }

  //---------------------------------------
  // Bind the socket to the local IP address
  // and port 27015
  hostent* thisHost;
  char* ip;
  u_short port;
  port = 80;
  thisHost = gethostbyname(&quot;&quot;);
  ip = inet_ntoa (*(struct in_addr *)*thisHost-&gt;h_addr_list);
  service.sin_family = AF_INET;
  service.sin_addr.s_addr = inet_addr(ip);
  service.sin_port = htons(port);

  if ( bind( ListenSocket,(SOCKADDR*) &amp;service, sizeof(service) )  == SOCKET_ERROR ) {
    printf(&quot;bind failed\n&quot;);
    closesocket(ListenSocket);
    return;
  }

  //---------------------------------------
  // Initialize variables and call setsockopt. 
  // The SO_KEEPALIVE parameter is a socket option 
  // that makes the socket send keepalive messages
  // on the session. The SO_KEEPALIVE socket option
  // requires a boolean value to be passed to the
  // setsockopt function. If TRUE, the socket is
  // configured to send keepalive messages, if FALSE
  // the socket configured to NOT send keepalive messages.
  // This section of code tests the setsockopt function
  // by checking the status of SO_KEEPALIVE on the socket
  // using the getsockopt function.
  int bOptVal = 100;
  int bOptLen = sizeof(BOOL);
  int iOptVal;
  int iOptLen = sizeof(int);

  if (getsockopt(ListenSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&amp;iOptVal, &amp;iOptLen) != SOCKET_ERROR) {
    printf(&quot;SO_RCVTIMEO Value: %ld\n&quot;, iOptVal);
  }

  if (setsockopt(ListenSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&amp;bOptVal,//hier bOptLen) != SOCKET_ERROR) { 
    printf(&quot;Set v: 100\n&quot;);
  }

  if (getsockopt(ListenSocket, SOL_SOCKET, SO_RCVTIMEO, (char*)&amp;iOptVal, &amp;iOptLen) != SOCKET_ERROR) {
    printf(&quot;SO_RCVTIMEO Value: %ld\n&quot;, iOptVal);
  }
  connect(ListenSocket,(SOCKADDR*) &amp;service,sizeof(service));
  WSACleanup();
  return;

}
</code></pre>
<p>Jedoch funktioniert das nicht - warum?<br />
Es kommt kein Fehler, aber Timout wieder ert nach einigen Sekunden.</p>
<p>anonymous2k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/665865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/665865</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Sat, 04 Dec 2004 16:58:53 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Thu, 09 Dec 2004 06:24:04 GMT]]></title><description><![CDATA[<p>Ich weiß, Doppel+Nervpost,<br />
aber weiß noch jemand Vorschläge?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/669257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/669257</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Thu, 09 Dec 2004 06:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Tue, 14 Dec 2004 19:26:05 GMT]]></title><description><![CDATA[<p>*auf ein letztes mal hoffend*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/673257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/673257</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Tue, 14 Dec 2004 19:26:05 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Wed, 15 Dec 2004 09:07:02 GMT]]></title><description><![CDATA[<p>Hi...</p>
<p>Also leider kann ich dir mit dem Timeoutproblem net helfen aber wenn du nur beabsichtigst deinen portscanner schneller zu machen dann lass ihn doch einfach paar Threads erstellen.</p>
<pre><code class="language-cpp">while(startport &lt;= endport+1)
{
 Sleep(5);
 CreateThread(0, 0, &amp;threadFkt, &amp;startport, 0, 0);
 startport++;
}
</code></pre>
<p>und deine Funktion</p>
<pre><code class="language-cpp">int ScanPort(String IP, int Port)
</code></pre>
<p>baust du einfach zum Thread um.<br />
Ich weiss net ob du das beachsichtigs aber vlt. hilft dir das hier was, so würds jedenfalls ich machen, wenn ich in schneller machen wollte.<br />
Wenn du ne Lösung für das Timeoutproblem gefunden hast poste mal bitte würde ich auch interessieren *g*.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/673499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/673499</guid><dc:creator><![CDATA[Tomjack]]></dc:creator><pubDate>Wed, 15 Dec 2004 09:07:02 GMT</pubDate></item><item><title><![CDATA[Reply to Port scannen? on Thu, 16 Dec 2004 18:36:23 GMT]]></title><description><![CDATA[<p>OK, stimmt, das ist auch eine Lösung!</p>
<p>Jo danke, mach ich mal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>anonymous2k</p>
]]></description><link>https://www.c-plusplus.net/forum/post/674826</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/674826</guid><dc:creator><![CDATA[anonymous2k]]></dc:creator><pubDate>Thu, 16 Dec 2004 18:36:23 GMT</pubDate></item></channel></rss>