前言:大家在挖比特币、门罗币等虚拟货币时,需要使用一些挖矿工具,这些工具在运行时需要附加多个参数,或者需要配置参数文件,放在服务器上,所有配置参数都是明文存储,会被别人轻易的发现并利用。今天我要分享给大家一种方法,可以自己定制挖矿工具,来避免参数明文存储的问题,还可以制作后门哦。
一、首先简单介绍下挖矿的流程。
1.申请钱包地址。
1).通过交易网站获得,例如gateio.io 和aex.com
交易网站可以参考非小号:https://www.feixiaohao.com/
2).通过官网钱包客户端来生成。
2.下载挖矿工具
本文主要以门罗币为例,使用的挖矿工具如:xmrig、xmr-stak等。
项目地址:
github.com/xmrig/xmrig(CPU挖矿)
github.com/xmrig/xmrig-amd(amd显卡挖矿))
http://github.com/xmrig/xmrig-nvidia(nvidia显卡挖矿)
https://github.com/fireice-uk/xmr-stak(CPU,显卡挖矿)
xmrig可以按照硬件环境来自由选择相应版本,而xmr-stak可以编译成软件包,一个软件包即可适用各种硬件环境(CPU、AMD显卡、Nvidia显卡)
3、配置挖矿参数
xmrig挖矿参数如下,以鱼池为例(f2pool,推荐几个矿池,见附录。)
cpu挖矿:xmrig.exe –max-cpu-usage 85 –cpu-priority 3 -o xmr.f2pool.com:13531 -u 钱包地址.矿工名 -p x -k
A卡:xmrig-amd.exe -o xmr.f2pool.com:13531 -u 钱包地址.矿工名 -p x -k
N卡:xmrig-nvidia.exe -o xmr.f2pool.com:13531 -u 钱包地址.矿工名 -p x -k
-a, --algo=ALGO specify the algorithm to use
cryptonight
cryptonight-lite
cryptonight-heavy
-o, --url=URL URL of mining server
-O, --userpass=U:P username:password pair for mining server
-u, --user=USERNAME username for mining server
-p, --pass=PASSWORD password for mining server
--rig-id=ID rig identifier for pool-side statistics (needs pool support)
-t, --threads=N number of miner threads
-v, --av=N algorithm variation, 0 auto select
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)
--nicehash enable nicehash.com support
--tls enable SSL/TLS support (needs pool support)
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning
-r, --retries=N number of times to retry before switch to backup server (default: 5)
-R, --retry-pause=N time to pause between retries (default: 5)
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)
--no-huge-pages disable huge pages support
--no-color disable colored output
--variant algorithm PoW variant
--donate-level=N donate level, default 5% (5 minutes in 100 minutes)
--user-agent set custom user-agent string for pool
-B, --background run the miner in the background
-c, --config=FILE load a JSON-format configuration file
-l, --log-file=FILE log all output to a file
-S, --syslog use system log for output messages
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)
--safe safe adjust threads and av settings for current CPU
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen.
--print-time=N print hashrate report every N seconds
--api-port=N port for the miner API
--api-access-token=T access token for API
--api-worker-id=ID custom worker-id for API
--api-id=ID custom instance ID for API
--api-ipv6 enable IPv6 support for API
--api-no-restricted enable full remote access (only if API token set)
--dry-run test configuration and exit
-h, --help display this help and exit
-V, --version output version information and exit
二、定制挖矿工具xmrig
1. ..\src\common\config\CommonConfig.cpp //配置默认参数以及矿池地址、钱包地址和密码。
xmrig::CommonConfig::CommonConfig() :
xmrig::CommonConfig::CommonConfig() :
m_algorithm(CRYPTONIGHT, VARIANT_AUTO), //设置挖矿算法,默认为CRYPTONIGHT
m_adjusted(false),
m_apiIPv6(false),
m_apiRestricted(true),
m_autoSave(true),
m_background(false), //如果为true则软件后台挖矿,不显示窗口,只创建进程。
m_colors(true), //设置颜色主题
m_dryRun(false),
m_syslog(false),
# ifdef XMRIG_PROXY_PROJECT
m_watch(true),
# else
m_watch(false), // TODO: enable config file watch by default when this feature propertly handled and tested.
# endif
m_apiPort(0),
m_donateLevel(kDefaultDonateLevel), //kDefaultDonateLevel为软件抽水比例,默认为百分之五,最小值为百分之一。即最小可以设置为1。
m_printTime(60),
m_retries(5),
m_retryPause(5),
m_state(NoneState)
{
m_pools.push_back(Pool(“矿池地址”,端口,”钱包地址”,”x”)); //端口为数字类型
# ifdef XMRIG_PROXY_PROJECT
m_retries = 2;
m_retryPause = 1;
# endif
}
2. ..\src\donate.h //设置软件抽水比例
constexpr const int kDefaultDonateLevel = 5; //抽水比例为百分之五,可以设置为1,同上。
constexpr const int kMinimumDonateLevel = 1;
3. ..\src\core\Config.cpp //设置CPU参数
xmrig::Config::Config() : xmrig::CommonConfig(),
m_aesMode(AES_AUTO),
m_algoVariant(AV_AUTO),
m_assembly(ASM_AUTO),
m_hugePages(true), //设置大内存交换,提高挖矿性能,需要配置系统参数
m_safe(true), //设置CPU安全使用参数,可以在系统资源紧张时,降低软件使用CPU资源的比例。
m_shouldSave(false),
m_maxCpuUsage(75), //设置CPU最大使用率,默认为%75
m_priority(-1)
三、编译xmrig(以widows 32位版本为例)
1、下载编译工具
下载依赖包,解压至C盘: https://github.com/xmrig/xmrig-deps/releases.
安装MSYS2:
http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe
http://repo.msys2.org/distrib/i686/msys2-i686-20180531.exe
安装gcc等编译环境
pacman -Sy
pacman -S mingw-w64-i686-gcc
pacman -S make
pacman -S mingw-w64-i686-cmake
pacman -S mingw-w64-i686-pkg-config
2、编译32位版本的xmrig
在xmrig的根目录下创建build文件夹:
mkdir build
cd build
使用cmake编译
cmake .. -G "Unix Makefiles" -DXMRIG_DEPS=c:/xmrig-deps-3.3/gcc/x86 -DWITH_HTTPD=OFF -DWITH_TLS=OFF
使用make编译
make -j4
-DWITH_LIBCPUID=OFF Disable libcpuid. Auto configuration of CPU after this will be very limited.
-DWITH_AEON=OFF Disable CryptoNight-Lite support.
-DWITH_HTTPD=OFF Build without built in http server and API.
-DWITH_TLS=OFF Disable SSL/TLS support.
-DWITH_ASM=OFF Disable ASM accelerated
行文有些粗糙,难免有些纰漏,还望读者海涵。有错误之处,望指正。
附矿池列表:(仅供参考)
国内:
鱼池:https://www.f2pool.com/
星火矿池:http://xmr.sparkpool.com/
国池:https://xmr.chinaenter.cn/#/home
皮皮虾矿池:https://xmr.c1d2.com/
nanopool:https://xmr.nanopool.org/
国外:
http://minexmr.com/
https://cn.minergate.com/xmr-mining-pool
