From 5d3573ef7a109ee70416fe94db098fe6a769a798 Mon Sep 17 00:00:00 2001 From: SkyperTHC Date: Tue, 3 Mar 2026 06:28:55 +0000 Subject: packetstorm sync --- other/telnetfp-0.1.2/base_net.cpp | 65 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 other/telnetfp-0.1.2/base_net.cpp (limited to 'other/telnetfp-0.1.2/base_net.cpp') diff --git a/other/telnetfp-0.1.2/base_net.cpp b/other/telnetfp-0.1.2/base_net.cpp new file mode 100644 index 0000000..0635985 --- /dev/null +++ b/other/telnetfp-0.1.2/base_net.cpp @@ -0,0 +1,65 @@ +class tcp_socket +{ + private: + int sock; + + public: + + int sopen (char *host, int port) + { + int x = -1; + struct hostent *foo = NULL; + struct sockaddr_in addr; + + memset ((struct sockaddr_in *) &addr, 0, sizeof (struct sockaddr_in)); + + if ((addr.sin_addr.s_addr = inet_addr (host)) == -1) + { + if ((foo = gethostbyname (host)) == NULL) + return -2; + addr.sin_addr.s_addr = *(unsigned long *) (foo->h_addr_list[0]); + } + addr.sin_family = PF_INET; + addr.sin_port = htons (port); + sock = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP); + + x = connect (sock, (struct sockaddr *) &addr, sizeof (struct sockaddr_in)); + if (x != 0 || sock < 0) + return -1; + + return 0; + } + + + char *sread (int x) + { + char *y = NULL; + y = (char *) malloc (x + 1); + memset (y, 0x00, x + 1); + if (read (sock, y, x) < 1) + { + free (y); + return NULL; + } + return y; + } + + + int swrite (char *x) + { + return write (sock, x, strlen (x)); + } + + + void sclose () + { + close (sock); + } + + + void + init () + { + sock = 0; + } +}; -- cgit v1.3