Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stratum/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ bool client_auth_by_workers(YAAMP_CLIENT *client)
// source = new YAAMP_SOURCE;
// memset(source, 0, sizeof(YAAMP_SOURCE));
//
// strncpy(source->ip, client->sock->ip, 1024);
// strncpy(source->ip, client->sock->ip, 64);
// source->speed = 1;
//
// g_list_source.AddTail(source);
Expand Down
5 changes: 3 additions & 2 deletions stratum/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// int count;
// double speed;
//
// char ip[1024];
// char ip[64];
//};

struct YAAMP_ALGO
{
char name[1024];
char name[64];
YAAMP_HASH_FUNCTION hash_function;

double diff_multiplier;
Expand Down Expand Up @@ -122,6 +122,7 @@ void get_random_key(char *key);

void client_sort();
void client_block_ip(YAAMP_CLIENT *client, const char *reason);
void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name);

bool client_reset_multialgo(YAAMP_CLIENT *client, bool first);
bool client_initialize_multialgo(YAAMP_CLIENT *client);
Expand Down
18 changes: 16 additions & 2 deletions stratum/client_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,25 @@ int client_ask(YAAMP_CLIENT *client, const char *method, const char *format, ...
void client_block_ip(YAAMP_CLIENT *client, const char *reason)
{
char buffer[1024];

sprintf(buffer, "iptables -A INPUT -s %s -p tcp --dport %d -j REJECT", client->sock->ip, g_tcp_port);
if(strcmp("0.0.0.0", client->sock->ip) == 0) return;
if(strstr(client->sock->ip, "192.168.")) return;
if(strstr(client->sock->ip, "127.0.0.")) return;

int s = system(buffer);
stratumlog("%s: %s blocked (%s)\n", g_stratum_algo, client->sock->ip, reason);
}

stratumlog("%s %s blocked (%s)\n", client->sock->ip, client->username, reason);
void client_block_ipset(YAAMP_CLIENT *client, const char *ipset_name)
{
char buffer[1024];
sprintf(buffer, "ipset -q -A %s %s", ipset_name, client->sock->ip);
if(strcmp("0.0.0.0", client->sock->ip) == 0) return;
if(strstr(client->sock->ip, "192.168.")) return;
if(strstr(client->sock->ip, "127.0.0.")) return;

int s = system(buffer);
stratumlog("%s: %s blocked via ipset %s %s\n", g_stratum_algo, client->sock->ip, ipset_name, client->username);
}

bool client_reset_multialgo(YAAMP_CLIENT *client, bool first)
Expand Down
2 changes: 1 addition & 1 deletion stratum/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ YAAMP_SOCKET *socket_initialize(int sock)
memset(&name, 0, len);

int res = getpeername(s->sock, (struct sockaddr *)&name, &len);
inet_ntop(AF_INET, &name.sin_addr, s->ip, 1024);
inet_ntop(AF_INET, &name.sin_addr, s->ip, 64);

res = getsockname(s->sock, (struct sockaddr *)&name, &len);
s->port = ntohs(name.sin_port);
Expand Down
2 changes: 1 addition & 1 deletion stratum/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

struct YAAMP_SOCKET
{
char ip[1024];
char ip[64];
int port;

// pthread_mutex_t mutex;
Expand Down
1 change: 1 addition & 0 deletions web/yaamp/core/functions/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function getAdminSideBarLinks()
{
$links = <<<end
<a href="/site/exchange">Exchanges</a>&nbsp;
<a href="/site/botnets">Botnets</a>&nbsp;
<a href="/site/user">Users</a>&nbsp;
<a href="/site/worker">Workers</a>&nbsp;
<a href="/site/version">Version</a>&nbsp;
Expand Down
9 changes: 9 additions & 0 deletions web/yaamp/modules/site/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@ public function actionTriggerAdd()

/////////////////////////////////////////////////

public function actionBotnets()
{
if(!$this->admin) return;

$this->render('botnets');
}

/////////////////////////////////////////////////

public function actionIndex()
{
if(isset($_GET['address']))
Expand Down
108 changes: 108 additions & 0 deletions web/yaamp/modules/site/botnets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

$this->pageTitle = 'Botnets';

echo getAdminSideBarLinks().'<br/><br/>';

//////////////////////////////////////////////////////////////////////////////////////

JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");

echo <<<end
<style type="text/css">
.red { color: darkred; }
table.dataGrid { max-width: 99.5%; }
table.dataGrid a.red { color: darkred; }
</style>
end;

showTableSorter('maintable', "{
tableClass: 'dataGrid',
textExtraction: {
4: function(node, table, n) { return $(node).attr('data'); }
},
widgets: ['zebra','Storage','saveSort'],
widgetOptions: {
saveSort: true
}
}");

echo <<<end
<thead>
<tr>
<th data-sorter="" width="20"></th>
<th data-sorter="text">Coin</th>
<th data-sorter="text">Algo</th>
<th data-sorter="text">Address</th>
<th data-sorter="numeric">Time</th>
<th data-sorter="numeric">PID</th>
<th data-sorter="numeric">IPs</th>
<th data-sorter="numeric">Workers</th>
<th data-sorter="text">Version</th>
<th data-sorter="false" align="right" class="actions" width="150">Actions</th>
</tr>
</thead><tbody>
end;

$botnets = dbolist("SELECT userid, algo, pid, max(time) AS time, count(userid) AS workers, count(DISTINCT ip) AS ips, max(version) AS version ".
" FROM workers GROUP BY userid, algo, pid HAVING ips > 10 ORDER BY ips DESC"
);

if(!empty($botnets))
foreach($botnets as $botnet)
{
if (!$botnet['userid']) continue;

$user = getdbo('db_accounts', $botnet['userid']);
if (!$user) continue;

$coin = getdbo('db_coins', $user->coinid);
if (!$coin) continue;

$coinsym = $coin->symbol;
$coinimg = CHtml::image($coin->image, $coin->symbol, array('width'=>'16'));
$coinlink = CHtml::link($coin->name, '/site/coin?id='.$coin->id);

$d = datetoa2($botnet['time']);

echo '<tr class="ssrow">';

echo '<td>'.$coinimg.'</td>';
echo '<td>'.$coinsym.'</td>';
echo '<td>'.$botnet['algo'].'</td>';
echo '<td>'.CHtml::link($user->username, '/?address='.$user->username).'</td>';
echo '<td data="'.$botnet['time'].'">'.$d.'</td>';
echo '<td>'.$botnet['pid'].'</td>';
echo '<td>'.$botnet['ips'].'</td>';
echo '<td>'.$botnet['workers'].'</td>';
echo '<td>'.$botnet['version'].'</td>';

echo '<td class="actions" align="right">';

if ($user->logtraffic)
echo '<a href="/site/loguser?id='.$user->id.'&en=0">unwatch</a> ';
else
echo '<a href="/site/loguser?id='.$user->id.'&en=1">watch</a> ';

if ($user->is_locked)
echo '<a href="/site/unblockuser?wallet='.$user->username.'">unblock</a> ';
else
echo '<a href="/site/blockuser?wallet='.$user->username.'">block</a> ';

echo '<a href="/site/banuser?id='.$user->id.'"><span class="red">BAN</span></a>';

echo '</td>';

echo '</tr>';
}

echo '</tbody>';

echo '<tfoot>';
if(empty($botnets)) {
echo '<tr><th colspan="10">'."No botnets detected".'</th></tr>';
}
echo '</tfoot>';

echo '</table><br>';
2 changes: 1 addition & 1 deletion web/yaamp/modules/site/results/mining_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function WriteBoxHeader($title)
} else {
echo "<td><b><a href='/site/block?id=$coin->id'>$name</a></b><span style='font-size: .8em'> ($coin->algo)</span></td>";
}
echo "<td align=right style='font-size: .8em;'><b>$reward $coin->symbol_show</a></td>";
echo "<td align=right style='font-size: .8em;'><b>$reward $coin->symbol_show</b></td>";

$title = "POW $coin->difficulty";
if($coin->rpcencoding == 'POS')
Expand Down