forked from SimoneHz/remove_miner_fees
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodevfee1.py
95 lines (77 loc) · 3.02 KB
/
nodevfee1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# based on:
# Demonlj comment
# https://stackoverflow.com/questions/27293924/change-tcp-payload-with-nfqueue-scapy?rq=1
# https://github.com/DanMcInerney/cookiejack/blob/master/cookiejack.py
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
import nfqueue
from scapy.all import *
import os
import re
from os import path
from datetime import datetime, timedelta
import json
from collections import OrderedDict
# https://forum.z.cash/t/about-dev-fees-and-how-to-remove-them/9600/36
#os.system('iptables -A OUTPUT -p tcp --dport 8008 -j NFQUEUE --queue-num 0') # for dwarfpool
os.system('iptables -A OUTPUT -p tcp --dport 9999 -d eth-eur.nanopool.org -j NFQUEUE --queue-num 0')
#os.system('iptables -A OUTPUT -p tcp --dport 5000 -j NFQUEUE --queue-num 0')
#os.system('iptables -A INPUT -p tcp --dport 5000 -j NFQUEUE --queue-num 0')
# miner fees iptables rule for mitm
#os.system('iptables -A FORWARD -o ens33 -p tcp --dport 4444 -d us1.ethermine.org -j NFQUEUE --queue-num 0')
my_eth_address = '0xf5ec8c6afc3dd2712b43b95128813bd09787a782'
def callback(arg1, payload):
data = payload.get_data()
pkt = IP(data)
payload_before = len(pkt[TCP].payload)
payload_text = str(pkt[TCP].payload)
# jason
print("%s:%s" % (datetime.now().strftime('%Y-%m-%d %H:%M:%S'), payload_text))
if ('submitLogin' in payload_text) or ('eth_login' in payload_text):
json_data=json.loads(payload_text, object_pairs_hook=OrderedDict)
if json_data['params']:
if my_eth_address not in json_data['params'][0]:
print('[*] DevFee Detected - Replacing Address - %s\n' % datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
print('[*] REPLACED FROM %s TO %s\n' % (json_data['params'][0], my_eth_address))
json_data['params'][0] = my_eth_address
print("[*] BEFORE: %s\n" % payload_text)
print("[*] AFTER: %s\n" % json.dumps(json_data))
payload_text=json.dumps(json_data) + '\n'
pkt[TCP].payload = payload_text
payload_after = len(payload_text)
payload_dif = payload_after - payload_before
pkt[IP].len = pkt[IP].len + payload_dif
pkt[IP].ttl = 40
del pkt[IP].chksum
del pkt[TCP].chksum
payload.set_verdict_modified(nfqueue.NF_ACCEPT, str(pkt), len(pkt))
def main():
q = nfqueue.queue()
q.open()
q.bind(socket.AF_INET)
q.set_callback(callback)
q.create_queue(0)
try:
q.try_run() # Main loop
except KeyboardInterrupt:
q.unbind(socket.AF_INET)
q.close()
if path.exists('./restart_iptables'):
os.system('./restart_iptables')
#ith regards to the restart_iptables script that's missing from the repo feel free to add this to satisfy the missing script. Perhaps a small contribution could be beneficial here
#!/bin/bash
#echo "Stopping firewall and allowing everyone..."
#ipt="/sbin/iptables"
#[ ! -x "$ipt" ] && { echo "$0: \"${ipt}\" command not found."; exit 1; }
#$ipt -P INPUT ACCEPT
#$ipt -P FORWARD ACCEPT
#$ipt -P OUTPUT ACCEPT
#$ipt -F
#$ipt -X
#$ipt -t nat -F
#$ipt -t nat -X
#$ipt -t mangle -F
#$ipt -t mangle -X
#$ipt -t raw -F
#$ipt -t raw -X
main()