本文为自己在centos 6.0下,利用cgminer-4.10.0进行比特币挖矿并利用tcpdump进行抓包分析的测试记录。
step 1 download and installwget http://ck.kolivas.org/apps/cgminer/cgminer-4.10.0.tar.bz2 #下载最新版本挖矿软件tar jxvf cgminer-4.10.0.tar.bz2 #解(。)压缩在当前目录cd cgminer-4.10.0.tar.bz2 #进入目录./configure --prefix=/usr/local/cgminer --enable-opencl --enable-maintainer-mode --enable-scrypt --enable-cpumining # --enable-cpumining这个参数是允许使用cpu进行挖矿,在没有gpu的情况下使用,如果有了gpu,不建议使用。make make checkmake installln -s /usr/local/cgminer/bin/cgminer /usr/binvim /usr/local/cgminer/etc/cgminer.conf #配置cgminer.confcgminer挖矿指令:cgminer -o stratum tcp://us.multipool.us:3332 -u cherishao_0 -p x #-0 指定矿池 -u 制定矿工 -p 密码
#挖矿成功输出“echo” cgminer version 4.10.0 - started: [2018-05-29 16:20:09] cpu algo: c--------------------------------------------------------------------------------(5s):664.3 (avg):647.7 kh/s | q:7 a:0 r:0 hw:0 e:0% u:0.0/mtq: 0 st: 2 ss: 0 dw: 0 nb: 1 lw: 0 gf: 0 rf: 0 wu: 0.0connected to http://us.multipool.us:3332 with lp as user cherishao_0block: 00000003e78a45bc9db17b5654bbe400... started: [16:20:09]--------------------------------------------------------------------------------[p]ool management [s]ettings [d]isplay options [q]uitcpu 0: | 647.0/647.7kh/s | a:0 r:0 hw:0 u:0.00/m--------------------------------------------------------------------------------[2018-05-29 16:20:09] started cgminer 4.10.0[2018-05-29 16:20:11] need to specify at least one pool server.input server details.url:http://us.multipool.us:3332username:cherishao_0password:x[2018-05-29 16:20:13] probing for an alive pool[2018-05-29 16:20:14] pool 0 http://us.multipool.us:3332 alive[2018-05-29 16:20:16] long-polling activated for http://us.multipool.us:3332/listenchannelstep2 tcpdump
@监视指定网络接口的数据包
tcpdump -i eth1
@指定ip,例如截获所有210.27.48.1 的主机收到的和发出的所有的数据包
tcpdump host 210.27.48.1
@监视指定主机和端口的数据包 如果想要获取主机210.27.48.1接收或发出的telnet包,使用如下命令
tcpdump tcp port 23 and host 210.27.48.1
@对本机的udp 123 端口进行监视 123 为ntp的服务端口
tcpdump udp port 123tcpdump 与wireshark
wireshark(以前是ethereal)是windows下非常简单易用的抓包工具。但在linux下很难找到一个好用的图形化抓包工具。
还好有tcpdump。我们可以用tcpdump wireshark 的完美组合实现:在 linux 里抓包,然后在windows 里分析包。
tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 192.168.1.0/24 -w ./target.cap
(1)tcp: ip icmp arp rarp 和 tcp、udp、icmp这些选项等都要放到第一个参数的位置,用来过滤数据报的类型
(2)-i eth1 : 只抓经过接口eth1的包
(3)-t : 不显示时间戳
(4)-s 0 : 抓取数据包时默认抓取长度为68字节。加上-s 0 后可以抓到完整的数据包
(5)-c 100 : 只抓取100个数据包
(6)dst port ! 22 : 不抓取目标端口是22的数据包
(7)src net 192.168.1.0/24 : 数据包的源网络地址为192.168.1.0/24
(8)-w ./target.cap : 保存成cap文件,方便用ethereal(即wireshark)分析
tcpdump -xvvennss 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854
@0x4745 为”get”前两个字母”ge”,0x4854 为”http”前两个字母”ht”。
tcpdump 对截获的数据并没有进行彻底解码,数据包内的大部分内容是使用十六进制的形式直接打印输出的。显然这不利于分析网络故障,通常的解决办法是先使用带-w参 数的tcpdump 截获数据并保存到文件中,然后再使用其他程序(如wireshark)进行解码分析。当然也应该定义过滤规则,以避免捕获的数据包填满整个硬盘。
step 3@可参考矿池配置
"pools": [ { "url": "aeon-pool.sqlnetcat.com:5555", // url of mining server "user": "wmsjrzgye77apyyprqrsfg6s3wybivswtkfd3bevqz3tqjhl7whgptojr4alkmptkmjymvqcxaak2j3lirgueyqz33vzhaexq", // username for mining server "pass": "x", // password for mining server "use-tls" : false, // enable tls for pool communication (need pool support) "keepalive": true, // send keepalived for prevent timeout (need pool support) "nicehash": false // enable nicehash/xmrig-proxy support }, { "url": "xmr.sqlnetcat.com:7777", // url of mining server "user": "47hmffjaykj7cxvvgrabefdbqzgtsi4gsyxanq3qandrdjuj3untdmmivg845l3sbhwsv8k9eajqdecb4gfmhcwilqjtyve", // username for mining server "pass": "x", // password for mining server "use-tls" : false, // enable tls for pool communication (need pool support) "keepalive": true, // send keepalived for prevent timeout (need pool support) "nicehash": false // enable nicehash/xmrig-proxy support }, { "url": "pool.minexmr.com:443", // url of mining server "user": "47hmffjaykj7cxvvgrabefdbqzgtsi4gsyxanq3qandrdjuj3untdmmivg845l3sbhwsv8k9eajqdecb4gfmhcwilqjtyve", // username for mining server "pass": "x", // password for mining server "use-tls" : false, // enable tls for pool communication (need pool support) "keepalive": true, // send keepalived for prevent timeout (need pool support) "nicehash": false // enable nicehash/xmrig-proxy support }, { "url": "xmr.crypto-pool.fr:443", // url of mining server "user": "47hmffjaykj7cxvvgrabefdbqzgtsi4gsyxanq3qandrdjuj3untdmmivg845l3sbhwsv8k9eajqdecb4gfmhcwilqjtyve", // username for mining server "pass": "x", // password for mining server "use-tls" : false, // enable tls for pool communication (need pool support) "keepalive": true, // send keepalived for prevent timeout (need pool support) "nicehash": false // enable nicehash/xmrig-proxy support } ],
@refer
tcpdump 使用指导书:https://www.cnblogs.com/losbyday/p/5851767.html
cgmier download website: http://ck.kolivas.org/apps/cgminer/
矿池:www.multipool.us
btc:1q31vf8dfdgudx7nm873ffxrsuvdokxmyj