下载软件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,正常情况下发送数据后此命令应该要退出的,但是一旦不能退出后面不管做什么操作都不能退出了,这是为何??