
49万USDT钱包资产被转走之到底是不是朋友干的?
话题背景wu351256@discord 有谁知道我的代币为什么会在我不知情的情况下下被转走,我查记录上面说是触发了什么智能合约。我是新手有大神带我理解一下嘛? 如果是触发了什么智能合约怎么找到这个合约并且解除合约进入正题@bmlcwenwu 是不是点了什么钓鱼链接?赶快去解除授权 @42069Imtoken里边有教程,先解除授权 @夜与昼 这种币被盗了,报警说不立案,imtoken客服说报警,投诉无门,欲哭无泪 @42069 国内加密货币属于非法,警察不立案。 @夜与昼 对啊,国内,我被盗了49万usdt夜与昼 @42069 这么多U,没想到用冷钱包吗 @夜与昼 我最后一次转账用我朋友的id下载的app,现在就是不知道会不会是他盗的 @42069 什么app? @夜与昼 Imtoken钱包 @42069 不是假的吧 @夜与昼 用他的id后,商城里下载的,登录进去给他转了一笔钱,一个星期后钱包被盗 @42069 登录之后退出id了吗?只是商城登录id没事 夜与昼登录后退出了,登录的时候还双重认证了, *[2:39 PM]*Icloud就会自动登陆 *[2:39 PM]*Iclou...
Etherscan事务交易详细分类
TransferERC21https://cn.etherscan.com/tx/0xc261caa5556785d46fbf5f715f4e5686288304a5a510d34336d763b060dc37b6Swap案例1: https://cn.etherscan.com/tx/0xf09f3b3dcd29552dac6fd14040bb457f3f462ab497dd4a885fcf1bcc026f10ff https://cn.etherscan.com/tx/0x23fdb4a895877af5d2091d541d05f6ae874267c8d82e73bb7f186d8839781c92ApproveERC20ERC721ERC1159https://cn.etherscan.com/tx/0x00ff492f7c93e50b47c1c341d935e5d5cac201455d7d7f8a491fd5f0a7d93746MintERC721MethodID: 0xa0712d68Function: mint(uint256 _mintAmount) MethodI...

以太坊签名验签原理揭秘
签名三大作用讨论密码学中的签名时,我们其实是在讨论所有权、有效性和完整性证明。举例来说,这些签名可以用来:证明你拥有地址的私钥(即认证功能);确保信息(例如,邮件)没有被篡改;验证你下载的 文件是合法有效的。签名基础原理:基于数学公式输入:一个输入消息、一个私钥和一个(通常情况下是秘密的)随机数,就可以得到一串数字作为输出值,也就是签名。 输出:使用另一个数学公式可以进行反向计算,在不知道私钥和随机数的情况下进行验证(译者注:即验证该签名是否出自跟某个公钥对应的私钥)。 这类算法有很多,如 RSA 和 AES,但是以太坊(和比特币)采用的都是椭圆曲线数字签名算法(ECDSA)。请注意,ECDSA 只是签名算法。与 RSA 和 AES 不同,这种算法不能用于加密。以太坊采用的是 secp256k1曲线。 签名方案由哈希算法和签名算法组成。以太坊选择的签名算法是secp256k1,哈希算法选择了keccak256,这是一个从字节串。不可逆计算通过椭圆曲线点乘算法(elliptic curve point manipulation),我们可以使用私钥计算出一个不可逆向计算的值(译者注:...
The infinite past has the present as its destination, and the infinite future has the present as its origin.

49万USDT钱包资产被转走之到底是不是朋友干的?
话题背景wu351256@discord 有谁知道我的代币为什么会在我不知情的情况下下被转走,我查记录上面说是触发了什么智能合约。我是新手有大神带我理解一下嘛? 如果是触发了什么智能合约怎么找到这个合约并且解除合约进入正题@bmlcwenwu 是不是点了什么钓鱼链接?赶快去解除授权 @42069Imtoken里边有教程,先解除授权 @夜与昼 这种币被盗了,报警说不立案,imtoken客服说报警,投诉无门,欲哭无泪 @42069 国内加密货币属于非法,警察不立案。 @夜与昼 对啊,国内,我被盗了49万usdt夜与昼 @42069 这么多U,没想到用冷钱包吗 @夜与昼 我最后一次转账用我朋友的id下载的app,现在就是不知道会不会是他盗的 @42069 什么app? @夜与昼 Imtoken钱包 @42069 不是假的吧 @夜与昼 用他的id后,商城里下载的,登录进去给他转了一笔钱,一个星期后钱包被盗 @42069 登录之后退出id了吗?只是商城登录id没事 夜与昼登录后退出了,登录的时候还双重认证了, *[2:39 PM]*Icloud就会自动登陆 *[2:39 PM]*Iclou...
Etherscan事务交易详细分类
TransferERC21https://cn.etherscan.com/tx/0xc261caa5556785d46fbf5f715f4e5686288304a5a510d34336d763b060dc37b6Swap案例1: https://cn.etherscan.com/tx/0xf09f3b3dcd29552dac6fd14040bb457f3f462ab497dd4a885fcf1bcc026f10ff https://cn.etherscan.com/tx/0x23fdb4a895877af5d2091d541d05f6ae874267c8d82e73bb7f186d8839781c92ApproveERC20ERC721ERC1159https://cn.etherscan.com/tx/0x00ff492f7c93e50b47c1c341d935e5d5cac201455d7d7f8a491fd5f0a7d93746MintERC721MethodID: 0xa0712d68Function: mint(uint256 _mintAmount) MethodI...

以太坊签名验签原理揭秘
签名三大作用讨论密码学中的签名时,我们其实是在讨论所有权、有效性和完整性证明。举例来说,这些签名可以用来:证明你拥有地址的私钥(即认证功能);确保信息(例如,邮件)没有被篡改;验证你下载的 文件是合法有效的。签名基础原理:基于数学公式输入:一个输入消息、一个私钥和一个(通常情况下是秘密的)随机数,就可以得到一串数字作为输出值,也就是签名。 输出:使用另一个数学公式可以进行反向计算,在不知道私钥和随机数的情况下进行验证(译者注:即验证该签名是否出自跟某个公钥对应的私钥)。 这类算法有很多,如 RSA 和 AES,但是以太坊(和比特币)采用的都是椭圆曲线数字签名算法(ECDSA)。请注意,ECDSA 只是签名算法。与 RSA 和 AES 不同,这种算法不能用于加密。以太坊采用的是 secp256k1曲线。 签名方案由哈希算法和签名算法组成。以太坊选择的签名算法是secp256k1,哈希算法选择了keccak256,这是一个从字节串。不可逆计算通过椭圆曲线点乘算法(elliptic curve point manipulation),我们可以使用私钥计算出一个不可逆向计算的值(译者注:...
The infinite past has the present as its destination, and the infinite future has the present as its origin.

Subscribe to Renaissance Labs

Subscribe to Renaissance Labs
Share Dialog
Share Dialog
<100 subscribers
<100 subscribers


Solidity 可以处理 256 位数字, 最高为 2^256 - 1, 所以对 (2^256 - 1) 加 1 会导致归 0。同理, 对 unsigned 类型 0 做减 1 运算会得到 (2**256 - 1)
pragma solidity 0.4.18;
contract OverflowUnderflow {
uint public zero = 0;
uint public max = 2^256 - 1;
// zero will end up at 2^256 - 1
function underflow() public {
zero -= 1;
}
function overflow() public {
max += 1;
}
}
比如, 账号 A 持有 X tokens, 如果他发起一笔 X + 1 tokens 的交易, 如果代码不进行校验, 则账号 A 的余额可能发生 underflow 导致余额变多.
可以引入 SafeMath Library 解决:
pragma solidity 0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a==0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract OverflowUnderflow {
using SafeMath for uint;
uint public zero = 0;
uint public max = 2 ** 256 - 1;
function underflow() public {
zero = zero.sub(1);
}
function overflow() public {
max = max.add(1);
}
}
Public functions 可以被任意地址调用
External functions 只能从合约外部调用
Private functions 只能从合约内部调用
Internal functions 允许从合约及其子合约调用
External functions 消耗的 gas 比 public 少, 因为其使用 calldata 而 Public 需要复制所有参数到 memory。
Delegatecall is identical to a message call apart from the fact that the code at the target address is executed in the context of the calling contract and msg.sender and msg.value do not change their values. This means that a contract can dynamically load code from a different address at runtime. Storage, current address and balance still refer to the calling contract, only the code is taken from the called address.
这个特性可以用于构建 Library 和模块化代码. 但是与此同时, 这也有可能造成别人对你的代码进行操作。
下例中, 攻击者调用 pwn 方法获得了合约的拥有权。
pragma solidity 0.4.18;
contract Delegate {
address public owner;
function Delegate(address _owner) public {
owner = _owner;
}
function pwn() public {
owner = msg.sender;
}
}
contract Deletagion {
address public owner;
Delegate delegate;
function Delegation(address _delegateAddreses) public {
delegate = Delegate(_delegateAddreses);
owner = msg.sender;
}
// an attacker can call Delegate.pwn() in the context of Delegation, this means that pwn() will modify the state of **Delegation** and not Delegate, the result is that the attacker takes unauthorized ownership of the contract.
function () public {
if(delegate.delegatecall(msg.data)) {
this;
}
}
}
Solidity 可以处理 256 位数字, 最高为 2^256 - 1, 所以对 (2^256 - 1) 加 1 会导致归 0。同理, 对 unsigned 类型 0 做减 1 运算会得到 (2**256 - 1)
pragma solidity 0.4.18;
contract OverflowUnderflow {
uint public zero = 0;
uint public max = 2^256 - 1;
// zero will end up at 2^256 - 1
function underflow() public {
zero -= 1;
}
function overflow() public {
max += 1;
}
}
比如, 账号 A 持有 X tokens, 如果他发起一笔 X + 1 tokens 的交易, 如果代码不进行校验, 则账号 A 的余额可能发生 underflow 导致余额变多.
可以引入 SafeMath Library 解决:
pragma solidity 0.4.18;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a==0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract OverflowUnderflow {
using SafeMath for uint;
uint public zero = 0;
uint public max = 2 ** 256 - 1;
function underflow() public {
zero = zero.sub(1);
}
function overflow() public {
max = max.add(1);
}
}
Public functions 可以被任意地址调用
External functions 只能从合约外部调用
Private functions 只能从合约内部调用
Internal functions 允许从合约及其子合约调用
External functions 消耗的 gas 比 public 少, 因为其使用 calldata 而 Public 需要复制所有参数到 memory。
Delegatecall is identical to a message call apart from the fact that the code at the target address is executed in the context of the calling contract and msg.sender and msg.value do not change their values. This means that a contract can dynamically load code from a different address at runtime. Storage, current address and balance still refer to the calling contract, only the code is taken from the called address.
这个特性可以用于构建 Library 和模块化代码. 但是与此同时, 这也有可能造成别人对你的代码进行操作。
下例中, 攻击者调用 pwn 方法获得了合约的拥有权。
pragma solidity 0.4.18;
contract Delegate {
address public owner;
function Delegate(address _owner) public {
owner = _owner;
}
function pwn() public {
owner = msg.sender;
}
}
contract Deletagion {
address public owner;
Delegate delegate;
function Delegation(address _delegateAddreses) public {
delegate = Delegate(_delegateAddreses);
owner = msg.sender;
}
// an attacker can call Delegate.pwn() in the context of Delegation, this means that pwn() will modify the state of **Delegation** and not Delegate, the result is that the attacker takes unauthorized ownership of the contract.
function () public {
if(delegate.delegatecall(msg.data)) {
this;
}
}
}
No activity yet