前言
本文为自己在Centos 6.0下,利用Cgminer-4.10.0进行比特币挖矿并利用Tcpdump进行抓包分析的测试记录。
Step 1 Download and install
wget 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 check
make install
ln -s /usr/local/cgminer/bin/cgminer /usr/bin
vim /usr/local/cgminer/etc/cgminer.conf #配置cgminer.conf
cgminer挖矿指令:
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/m
TQ: 0 ST: 2 SS: 0 DW: 0 NB: 1 LW: 0 GF: 0 RF: 0 WU: 0.0
Connected to http://us.multipool.us:3332 with LP as user Cherishao_0
Block: 00000003e78a45bc9db17b5654bbe400... Started: [16:20:09]
--------------------------------------------------------------------------------
[P]ool management [S]ettings [D]isplay options [Q]uit
CPU 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:3332
Username:
Cherishao_0
Password:
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/listenChannel
Step2 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 123
tcpdump 与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抓取HTTP包
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