编译netcat

博客讲述在Linux系统下载并解压netcat - 0.7.1软件,该软件只依赖动态libc库。同时提出问题,使用netcat发送数据时,如执行特定命令后,正常应退出但有时无法退出,后续操作也无法退出。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

下载软件netcat-0.7.1,拷贝到Linux系统并解压:

[yubo.wang@localhost netcat-0.7.1]$ mkdir build
[yubo.wang@localhost netcat-0.7.1]$ cd build/
[yubo.wang@localhost netcat-0.7.1]$ ../configure --host=arm-linux --prefix=$PWD CC=/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/bin/arm-hisiv300-linux-gcc
[yubo.wang@localhost netcat-0.7.1]$ make
[yubo.wang@localhost netcat-0.7.1]$ make install

[yubo.wang@localhost build]$ readelf -h bin/netcat 
ELF 头:
  Magic:  7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  类别:                              ELF32
  数据:                              2 补码,小端序 (little endian)
  版本:                              1 (current)
  OS/ABI:                            UNIX - System V
  ABI 版本:                          0
  类型:                              EXEC (可执行文件)
  系统架构:                          ARM
  版本:                              0x1
  入口点地址:              0x9e3c
  程序头起点:              52 (bytes into file)
  Start of section headers:          97884 (bytes into file)
  标志:             0x5000202, Version5 EABI, soft-float ABI, <unknown>
  本头的大小:       52 (字节)
  程序头大小:       32 (字节)
  Number of program headers:         6
  节头大小:         40 (字节)
  节头数量:         33
  字符串表索引节头: 30
[yubo.wang@localhost build]$ readelf -d bin/netcat 

Dynamic section at offset 0x75fc contains 21 entries:
  标记        类型                         名称/值
 0x00000001 (NEEDED)                     共享库:[libc.so.0]
 0x0000000c (INIT)                       0x8d94
 0x0000000d (FINI)                       0xdfb8
 0x00000019 (INIT_ARRAY)                 0x175f0
 0x0000001b (INIT_ARRAYSZ)               4 (bytes)
 0x0000001a (FINI_ARRAY)                 0x175f4
 0x0000001c (FINI_ARRAYSZ)               4 (bytes)
 0x00000004 (HASH)                       0x8108
 0x00000005 (STRTAB)                     0x8898
 0x00000006 (SYMTAB)                     0x8368
 0x0000000a (STRSZ)                      684 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x176cc
 0x00000002 (PLTRELSZ)                   544 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x8b74
 0x00000011 (REL)                        0x8b44
 0x00000012 (RELSZ)                      48 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x00000000 (NULL)                       0x0

只依赖一个动态libc库

~ # netcat --help
GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere:  netcat [options] hostname port [port] ...
listen for inbound:    netcat -l -p port [options] [hostname] [port] ...
tunnel to somewhere:   netcat -L hostname:port -p port [options]

Mandatory arguments to long options are mandatory for short options too.
Options:
  -c, --close                close connection on EOF from stdin
  -e, --exec=PROGRAM         program to exec after connect
  -g, --gateway=LIST         source-routing hop point[s], up to 8
  -G, --pointer=NUM          source-routing pointer: 4, 8, 12, ...
  -h, --help                 display this help and exit
  -i, --interval=SECS        delay interval for lines sent, ports scanned
  -l, --listen               listen mode, for inbound connects
  -L, --tunnel=ADDRESS:PORT  forward local port to remote address
  -n, --dont-resolve         numeric-only IP addresses, no DNS
  -o, --output=FILE          output hexdump traffic to FILE (implies -x)
  -p, --local-port=NUM       local port number
  -r, --randomize            randomize local and remote ports
  -s, --source=ADDRESS       local source address (ip or hostname)
  -t, --tcp                  TCP mode (default)
  -T, --telnet               answer using TELNET negotiation
  -u, --udp                  UDP mode
  -v, --verbose              verbose (use twice to be more verbose)
  -V, --version              output version information and exit
  -x, --hexdump              hexdump incoming and outgoing traffic
  -w, --wait=SECS            timeout for connects and final net reads
  -z, --zero                 zero-I/O mode (used for scanning)

Remote port number can also be specified as range.  Example: '1-1024'

问题

1、有时候发送数据后命令不能退出

netcat -lp 1234

echo "hello" | nc 192.168.10.254 1234,正常情况下发送数据后此命令应该要退出的,但是一旦不能退出后面不管做什么操作都不能退出了,这是为何??

 

 

 

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值