nc 源代码分析(1)【nc用作聊天工具】

nc 源代码分析(1)【nc用作聊天工具】客户端 ncipportread 服务端 nc l pportreadfdw 客户端和服务端都是用的 nc exe 都要连接既 doconnect 然后得到一个句柄 netfd 所不同的

大家好,欢迎来到IT知识分享网。



客户端:nc ip port

read stdin write fd

服务端: nc -l -p port

read fd write stdout

客户端和服务端都是用的nc.exe都要连接既doconnect

然后得到一个句柄netfd,

所不同的是服务端和客户端在执行readwrite的时候有所区别!



read fd write stdout

/* main :
   now we pull it all together… */
main (argc, argv)
  int argc;
  char argv;
{








      netfd = doconnect(themaddr, curport, ouraddr, ourport);

Debug ((“netfd %d from port %d to port %d”, netfd, ourport, curport))
      if (netfd > 0)
    if (o_zero && o_udpmode)    /* if UDP scanning… */
      netfd = udptest (netfd, themaddr);
      if (netfd > 0) {            /* Yow, are we OPEN YET?! */
        x = 0;                /* pre-exit status */
        holler (“%s [%s] %d (%s) open”,
          whereto->name, whereto->addrs[0], curport, portpoop->name);
#ifdef GAPING_SECURITY_HOLE
        if (pr00gie)            /* exec is valid for outbound, too */
    doexec (netfd);
#endif /* GAPING_SECURITY_HOLE */
    if (! o_zero)
#ifdef WIN32
#ifdef GAPING_SECURITY_HOLE
    if (!pr00gie)  // doexec does the read/write for win32
#endif
#endif
      x = readwrite (netfd);    /* go shovel shit */

























  if (Single)
    exit (x);            /* give us status on one connection */
  exit (0);            /* otherwise, we’re just done */
  return(0);
} /* main */




免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/127605.html

(0)
上一篇 2025-09-06 15:20
下一篇 2025-09-06 15:33

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信