summaryrefslogtreecommitdiff
path: root/exploits/7350php/network.h
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /exploits/7350php/network.h
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'exploits/7350php/network.h')
-rw-r--r--exploits/7350php/network.h367
1 files changed, 367 insertions, 0 deletions
diff --git a/exploits/7350php/network.h b/exploits/7350php/network.h
new file mode 100644
index 0000000..3e726d0
--- /dev/null
+++ b/exploits/7350php/network.h
@@ -0,0 +1,367 @@
1/* scut's leet network library ;)
2 * 1999 (c) scut
3 *
4 * networking code
5 */
6
7#ifndef SCUT_NETWORK_H
8#define SCUT_NETWORK_H
9
10#include <sys/socket.h>
11#include <net/if.h>
12#include <netinet/in.h>
13#include <stdio.h>
14
15#define NET_READTIMEOUT 180
16#define NET_CONNTIMEOUT 60
17#define NET_IDENTTIMEOUT 15
18
19#define IFI_NAME 16
20#define IFI_HADDR 8
21
22/* struct ifi_info
23 *
24 * a linked list giving information about all the network interfaces available
25 * a pointer to this struct list is returned by net_get_ifi.
26 */
27
28struct ifi_info {
29 char ifi_name[IFI_NAME];
30 u_char ifi_haddr[IFI_HADDR];
31 u_short ifi_hlen;
32 short ifi_flags;
33 short ifi_myflags;
34 struct sockaddr *ifi_addr;
35 struct in_addr ifi_saddr;
36 struct ifi_info *ifi_next;
37};
38
39#define IFI_ALIAS 1
40
41typedef struct bound {
42 int bs; /* bound socket */
43 unsigned short port; /* port we bound to */
44 struct sockaddr bsa; /* bs_in */
45} bound;
46
47extern int net_readtimeout;
48extern int net_conntimeout;
49extern int net_identtimeout;
50
51
52/* net_socks_connect
53 *
54 * relays through an open socks 5 server (NO AUTH type)
55 * returns a socket descriptor which is already connected
56 */
57
58int net_socks_connect (char *socks, unsigned short int sport,
59 char *server, unsigned short int port, int sec);
60
61
62/* net_socks_put_s5info
63 *
64 * insert socks 5 compatible relay information into socket s5s,
65 * used to relay over more then just one socks server
66 */
67
68int net_socks_put_s5info (int s5s, char *server,
69 unsigned short int port, int sec);
70
71
72/* net_parseip
73 *
74 * read an ip in the format "1.1.1.1:299" or "blabla:481" into
75 * the char pointer *ip and into the port *port
76 *
77 * return 0 on failure
78 * return 1 on success
79 */
80
81int net_parseip (char *inp, char **ip, unsigned short int *port);
82
83
84/* net_getlocalip
85 *
86 * give back the main IP of the local machine
87 *
88 * return the local IP address as string on success
89 * return NULL on failure
90 */
91
92char *net_getlocalip (void);
93
94
95/* net_peeraddress
96 *
97 * return a pointer to a string representation of the remote IP address of
98 * the already connected socket `socket'
99 *
100 * return NULL on failure
101 * return string pointer on succes
102 */
103
104char * net_peeraddress (int socket);
105
106
107/* net_addrpair
108 *
109 * find address pair of an established TCP connection of socket `socket'.
110 *
111 * return 0 on success
112 * return 1 on failure
113 */
114
115int
116net_addrpair (int socket, struct in_addr *src_ip, unsigned short int *src_prt,
117 struct in_addr *dst_ip, unsigned short int *dst_prt);
118
119
120/* net_peername
121 *
122 * return a pointer that points to an alloced character array that contains
123 * the fully qualified hostname for the remote host that is connected using
124 * the socket descriptor `socket'.
125 +
126 * return NULL on failure
127 * return pointer to hostname or quad-dotted IP address
128 */
129
130char *net_peername (int socket);
131
132
133/* net_descriptify
134 *
135 * descriptify a socket `socket' ;)
136 *
137 * return -1 on failure
138 * return file descriptor on success
139 */
140
141FILE *net_descriptify (int socket);
142
143
144/* net_ident
145 *
146 * ident a connection identified by the host:port pairs on both sides,
147 * returning the ident in *ident
148 *
149 * return 1 on success
150 * return -1 on failure
151 */
152
153int net_ident (char **ident, struct sockaddr_in *locals, unsigned short int localport,
154 struct sockaddr_in *remotes, unsigned short int remoteport);
155
156
157/* net_accept
158 *
159 * accept a connection from socket s, and stores the connection
160 * into cs.
161 * wait a maximum amount of maxsec seconds for connections
162 * maxsec can also be zero (infinite wait, until connection)
163 *
164 * return 0 if no connection has been made within maxsec seconds
165 * return -1 if an error appears
166 * return the socket number if a connection has been made
167 */
168
169int net_accept (int s, struct sockaddr_in *cs, int maxsec);
170
171
172/* net_get_ifi
173 *
174 * get network interface information
175 *
176 * return NULL on failure
177 * return a pointer to a linked list structure ifi_info (see above)
178 */
179
180struct ifi_info *net_ifi_get (int family, int doaliases);
181
182
183/* net_ifi_free
184 *
185 * free the linked list associated with `tf'.
186 *
187 * return in any case
188 */
189
190void net_ifi_free (struct ifi_info *tf);
191
192
193/* net_testvip
194 *
195 * test if virtual ip/hostname is available for use on the local machine,
196 *
197 * return 1 if the ip can be used
198 * return 0 if the ip/host is not available
199 */
200
201int net_testvip (char *ip);
202
203
204/* net_bind
205 *
206 * bind a socket to an ip:port on the local machine,
207 * `ip' can be either NULL (bind to all IP's on the host), or a pointer
208 * to a virtual host name, or a real IP, or "*" for any.
209 * `port' can be either 0 (ephemeral port), or any free port.
210 *
211 * return NULL on failure
212 * return pointer to bound structure on success
213 */
214
215bound *net_bind (char *ip, unsigned short int port);
216
217
218/* net_boundfree
219 *
220 * free the bound structure pointed to by `bf'
221 *
222 * return in any case
223 */
224
225void net_boundfree (bound *bf);
226
227
228/* net_resolve
229 *
230 * resolve a hostname pointed to by `host' into a s_addr return value
231 *
232 * return the correct formatted `s_addr' for this host on success
233 * return 0 on failure
234 */
235
236unsigned long int net_resolve (char *host);
237
238
239/* net_assignaddr
240 *
241 * assign an IP address and port to a socket
242 * sourceip can be an IP or hostname that is available on the local host,
243 * or NULL/"*" to let the kernel choose one, same applies to sourceport,
244 * it can either be zero (ephemeral port choosen by the kernel) or a
245 * valid port number
246 *
247 * return 1 on success
248 * return 0 on failure
249 */
250
251int net_assignaddr (int sd, char *sourceip, unsigned short int sourceport);
252
253
254/* net_connect
255 *
256 * connect to the given `server' and `port' with a max timeout of `sec'.
257 * initialize the sockaddr_in struct `cs' correctly (ipv4), accept any
258 * ip "123.123.123.123" or hostname "localhost", "www.yahoo.de" as hostname.
259 * create a new socket and return either -1 if failed or
260 * the connected socket if connection has been established within the
261 * timeout limit.
262 *
263 * the routine is still IPv4 biased :-/
264 * with `sourceip'/`sourceportÄ you MAY specify the source IP and source port
265 * to use for the connection, but you can set the ip or port to NULL/0,
266 * to choose the default IP and an ephemeral port. this was added later in
267 * this library, so please update your sources.
268 *
269 * return -1 on failure
270 * return socket if success
271 */
272
273int net_connect (struct sockaddr_in *cs, char *server, unsigned short int port, char *sourceip,
274 unsigned short int sourceport, int sec);
275
276
277/* net_rtimeout
278 *
279 * waits max `sec' seconds for fd to become readable
280 *
281 * return -1 on error (errno set)
282 * return 1 on readability
283 */
284
285int net_rtimeout (int fd, int sec);
286
287
288/* net_rbuf
289 *
290 * allocate memory and read socket data to `dst' until the connection
291 * gets closed.
292 *
293 * return n if success (n = number of bytes read)
294 * return -1 if failed
295 */
296
297long int net_rbuf (int fd, char **dst);
298#define NET_BSIZE 4096 /* blocksize for pre-allocation */
299
300
301/* net_rbuft
302 *
303 * read `dsize' bytes into `dst' from `fd', with timeout
304 *
305 * return 1 on success
306 * return -1 on failure
307 */
308int net_rbuft (int fd, char *dst, unsigned long int dsize);
309
310
311/* net_rlinet
312 *
313 * read a line from socket descriptor with timeout to buffer
314 * if sec = 0, then only a continuous stream of data is required, not
315 * an overall timeout.
316 *
317 * return -1 on timeout
318 * return 0 on connection close
319 * return length of readen line (including '\n')
320 *
321 * net_rlineta
322 * same as net_rlinet, but allocs the memory itself
323 */
324
325int net_rlineta (int fd, char **buf, int sec);
326int net_rlinet (int fd, char *buf, int bufsize, int sec);
327
328
329/* net_tline
330 *
331 * return length if string `buf' with a maximum length of `bufsize'
332 * contains '\n'
333 *
334 * return -1 if no '\n' in string
335 */
336
337int net_tline (char *buf, int bufsize);
338
339
340/* net_write
341 *
342 * print a formatted string to a socket, see syntax of printf
343 *
344 * return in any case
345 */
346
347void net_write (int fd, const char *str, ...);
348
349
350/* net_printip
351 *
352 * print an IP address stored in the struct in_addr pointed to by `ia' to a
353 * string `str' with a maximum length of `len'.
354 *
355 * return 0 on success
356 * return 1 on failure
357 *
358 * net_printipa behaves the same way, except it allocates memory and let
359 * `*str' point to the string
360 */
361
362int net_printip (struct in_addr *ia, char *str, size_t len);
363int net_printipa (struct in_addr *ia, char **str);
364
365
366#endif
367