Bitcoin Forum
November 16, 2024, 10:20:51 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mincoin difficulty coaster exploit script  (Read 2192 times)
tacotime (OP)
Legendary
*
Offline Offline

Activity: 1484
Merit: 1005



View Profile
April 03, 2013, 03:42:32 PM
 #1

Quote from: manface
Considering you were one of the first posters in here complaining about how you couldn't work out how to download the blockchain I doubt you could do much of anything.

Litecoin:
Code:
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
{
    // Testnet has min-difficulty blocks
    // after nTargetSpacing*2 time between blocks:
    if (fTestNet && nTime > nTargetSpacing*2)
        return bnProofOfWorkLimit.GetCompact();

    CBigNum bnResult;
    bnResult.SetCompact(nBase);
    while (nTime > 0 && bnResult < bnProofOfWorkLimit)
    {
        // Maximum 400% adjustment...
        bnResult *= 4;
        // ... in best-case exactly 4-times-normal target time
        nTime -= nTargetTimespan*4;
    }
    if (bnResult > bnProofOfWorkLimit)
        bnResult = bnProofOfWorkLimit;
    return bnResult.GetCompact();
}

unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlock *pblock)
{
    unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact();

    // Genesis block
    if (pindexLast == NULL)
        return nProofOfWorkLimit;

    // Only change once per interval
    if ((pindexLast->nHeight+1) % nInterval != 0)
    {
        // Special difficulty rule for testnet:
        if (fTestNet)
        {
            // If the new block's timestamp is more than 2* 10 minutes
            // then allow mining of a min-difficulty block.
            if (pblock->nTime > pindexLast->nTime + nTargetSpacing*2)
                return nProofOfWorkLimit;
            else
            {
                // Return the last non-special-min-difficulty-rules-block
                const CBlockIndex* pindex = pindexLast;
                while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit)
                    pindex = pindex->pprev;
                return pindex->nBits;
            }
        }

        return pindexLast->nBits;
    }

Mincoin:
Code:
unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
{
    // Testnet has min-difficulty blocks
    // after nTargetSpacing*2 time between blocks:
    if (fTestNet && nTime > nTargetSpacing*2)
        return bnProofOfWorkLimit.GetCompact();

    CBigNum bnResult;
    bnResult.SetCompact(nBase);
    while (nTime > 0 && bnResult < bnProofOfWorkLimit)
    {
        // Maximum 400% adjustment...
        bnResult *= 4;
        // ... in best-case exactly 4-times-normal target time
        nTime -= nTargetTimespan*4;
    }
    if (bnResult > bnProofOfWorkLimit)
        bnResult = bnProofOfWorkLimit;
    return bnResult.GetCompact();
}

unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlock *pblock)
{
    unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact();

    // Genesis block
    if (pindexLast == NULL)
        return nProofOfWorkLimit;

    // Only change once per interval
    if ((pindexLast->nHeight+1) % nInterval != 0)
    {
        // Special difficulty rule for testnet:
        if (fTestNet)
        {
            // If the new block's timestamp is more than 2* 10 minutes
            // then allow mining of a min-difficulty block.
            if (pblock->nTime > pindexLast->nTime + nTargetSpacing*2)
                return nProofOfWorkLimit;
            else
            {
                // Return the last non-special-min-difficulty-rules-block
                const CBlockIndex* pindex = pindexLast;
                while (pindex->pprev && pindex->nHeight % nInterval != 0 && pindex->nBits == nProofOfWorkLimit)
                    pindex = pindex->pprev;
                return pindex->nBits;
            }
        }

        return pindexLast->nBits;
    }

--> Chain is still vulnerable to coaster exploit, in fact even more so because of the faster retarget

Code for exploit (Unix, Python 2.7)
Code:
from subprocess import Popen, PIPE, STDOUT
import time
import json
import math

class Min(object):
    def __init__(self, blocks):
        self.blocks = blocks

scan_time = 5

while(True):
    ### Get the initial block number from mincoind, store in output_j['blocks']
    cmd = './mincoind getinfo' ### Command for dumping info from mincoind in json format; we use this lots
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) ### Execute command
    output = p.stdout.read() ### Read the stdout that output gives us
    output_j = json.loads(output) ### Convert from json to python values; we call block number using the class given above
    print("Current block is " + str(output_j['blocks']))

    if (math.floor(output_j['blocks']/720) % 2 == 0): ### During exploit period of 720 blocks, mine MinCoin
        print ("Exploit block, mining mincoin...")

        mincoin_config = open('minmine.conf','r')
        card_config = open('cardconf.conf','r')
        configuration = open('litecoin.conf', 'w')

        ### Copy the reaper configuration to litecoin.conf for mincoin
        for line in mincoin_config:
            configuration.write(line)
        for line in card_config:
            configuration.write(line)

        mincoin_config.close()
        card_config.close()
        configuration.close()

        miner_cmd = './reaper' ### Command for your miner to mine NVC
        miner_thread = Popen(miner_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)

        ### Loop below checks to see when block we're on, terminates miner if we are on an off number block
        while(True):
            p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
            output = p.stdout.read()
            output_j = json.loads(output)
            if not(math.floor(output_j['blocks']/720) % 2 == 0):
                miner_thread.terminate()
                break
            else:
                print("Block height still in exploit period, mining mincoin.")
                time.sleep(scan_time)

    else: ### Block is not exploit, mine something else
        print ("Non-exploit block, mining another chain...")

        mincoin_config = open('elsemine.conf','r')
        card_config = open('cardconf.conf','r')
        configuration = open('litecoin.conf', 'w')

        ### Copy the reaper configuration to litecoin.conf for other chain
        for line in mincoin_config:
            configuration.write(line)
        for line in card_config:
            configuration.write(line)

        mincoin_config.close()
        card_config.close()
        configuration.close()

        miner_cmd = './reaper' ### Command for your miner to mine something else; the same here because we use reaper
        miner_thread = Popen(miner_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)

        ### Loop below checks to see when block we're on, terminates miner if we are on an exploit number block
        while(True):
            p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
            output = p.stdout.read()
            output_j = json.loads(output)
            if (math.floor(output_j['blocks']/720) % 2 == 0):
                miner_thread.terminate()
                break
            else:
                print("Block not exploit height, mining another chain.")
                time.sleep(scan_time)

Code for exploit (Windows, Python 2.7)
Code:
from subprocess import Popen, PIPE, STDOUT
import time
import json
import math

class Min(object):
    def __init__(self, blocks):
        self.blocks = blocks

scan_time = 5

while(True):
    ### Get the initial block number from mincoind, store in output_j['blocks']
    cmd = 'mincoind.exe getinfo' ### Command for dumping info from mincoind in json format; we use this lots
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) ### Execute command
    output = p.stdout.read() ### Read the stdout that output gives us
    output_j = json.loads(output) ### Convert from json to python values; we call block number using the class given above
    print("Current block is " + str(output_j['blocks']))

    if (math.floor(output_j['blocks']/720) % 2 == 0): ### During exploit period of 720 blocks, mine MinCoin
        print ("Exploit block, mining mincoin...")

        mincoin_config = open('minmine.conf','r')
        card_config = open('cardconf.conf','r')
        configuration = open('litecoin.conf', 'w')

        ### Copy the reaper configuration to litecoin.conf for mincoin
        for line in mincoin_config:
            configuration.write(line)
        for line in card_config:
            configuration.write(line)

        mincoin_config.close()
        card_config.close()
        configuration.close()

        miner_cmd = 'reaper.exe' ### Command for your miner to mine NVC
        miner_thread = Popen(miner_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)

        ### Loop below checks to see when block we're on, terminates miner if we are on an off number block
        while(True):
            p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
            output = p.stdout.read()
            output_j = json.loads(output)
            if not(math.floor(output_j['blocks']/720) % 2 == 0):
                miner_thread.terminate()
                break
            else:
                print("Block height still in exploit period, mining mincoin.")
                time.sleep(scan_time)

    else: ### Block is not exploit, mine something else
        print ("Non-exploit block, mining another chain...")

        mincoin_config = open('elsemine.conf','r')
        card_config = open('cardconf.conf','r')
        configuration = open('litecoin.conf', 'w')

        ### Copy the reaper configuration to litecoin.conf for other chain
        for line in mincoin_config:
            configuration.write(line)
        for line in card_config:
            configuration.write(line)

        mincoin_config.close()
        card_config.close()
        configuration.close()

        miner_cmd = 'reaper.exe' ### Command for your miner to mine something else; the same here because we use reaper
        miner_thread = Popen(miner_cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)

        ### Loop below checks to see when block we're on, terminates miner if we are on an exploit number block
        while(True):
            p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
            output = p.stdout.read()
            output_j = json.loads(output)
            if (math.floor(output_j['blocks']/720) % 2 == 0):
                miner_thread.terminate()
                break
            else:
                print("Block not exploit height, mining another chain.")
                time.sleep(scan_time)

Requires the following files to exist:
mincoind executable that is running prior to executing the python code above
reaper executable
reaper.conf (configured as per normal)
Requires reaper and mincoind to be in the same directory

minmine.conf:
Code:
host minecoinhost
port ????
user username
pass password
elsemine.conf (mines litecoin or whatever with reaper)
Code:
host litecoinhost
port ????
user username
pass password
cardconf.conf (configuration for scrypt):
Code:

protocol litecoin

worksize 256
vectors 1
aggression 20
threads_per_gpu 1
sharethreads 32
lookup_gap 2
gpu_thread_concurrency ####

Code:
XMR: 44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns
tacotime (OP)
Legendary
*
Offline Offline

Activity: 1484
Merit: 1005



View Profile
April 03, 2013, 03:49:21 PM
 #2

Whoops, forgot to change a couple of lines, should work now

Not that anyone is mining mincoin anyway

Code:
XMR: 44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns
phantastisch
Legendary
*
Offline Offline

Activity: 2271
Merit: 1363



View Profile
April 03, 2013, 03:53:34 PM
 #3

Whoops, forgot to change a couple of lines, should work now

Not that anyone is mining mincoin anyway

Your Litecoin & Mincoin Code examples read identic to me , is this intended?

HOWEYCOINS   ▮      Excitement and         ⭐  ● TWITTER  ● FACEBOOK   ⭐       
  ▮    guaranteed returns                 ●TELEGRAM                         
  ▮  of the travel industry
    ⭐  ●Ann Thread ●Instagram   ⭐ 
✅    U.S.Sec    ➡️
✅  approved!  ➡️
tacotime (OP)
Legendary
*
Offline Offline

Activity: 1484
Merit: 1005



View Profile
April 03, 2013, 03:55:47 PM
 #4

Your Litecoin & Mincoin Code examples read identic to me , is this intended?

Yes, it's a problem with litecoin (and bitcoin) as diff changes are ONLY based upon the retarget period.  However, if your retarget period is long enough it's not a problem -- the shorter the retarget, the more exploitable the chain.  About 5 months ago the problem was bad for litecoin, but now as litecoin is worth much more than bitcoin, chain hopping is discouraged and it's not really a problem.  PPcoin (and now with Sunny King's help, TRC) addressed this by basing retarget on longer moving average periods.

Was used successfully for TRC here: https://bitcointalk.org/index.php?topic=157449.0

Although not by me, I only wrote the script.

Code:
XMR: 44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns
bushstar
Hero Member
*****
Offline Offline

Activity: 617
Merit: 531


View Profile
April 03, 2013, 03:56:30 PM
 #5

Thanks for that Taco. Very interesting.

phantastisch
Legendary
*
Offline Offline

Activity: 2271
Merit: 1363



View Profile
April 03, 2013, 03:58:31 PM
 #6

Your Litecoin & Mincoin Code examples read identic to me , is this intended?

Yes, it's a problem with litecoin (and bitcoin) as diff changes are ONLY based upon the retarget period.  However, if your retarget period is long enough it's not a problem -- the shorter the retarget, the more exploitable the chain.  About 5 months ago the problem was bad for litecoin, but now as litecoin is worth much more than bitcoin, chain hopping is discouraged and it's not really a problem.  PPcoin (and now with Sunny King's help, TRC) addressed this by basing retarget on longer moving average periods.

thx, i thought at first mincoin changed something after forking from litecoin and where now susceptible to this attack.

HOWEYCOINS   ▮      Excitement and         ⭐  ● TWITTER  ● FACEBOOK   ⭐       
  ▮    guaranteed returns                 ●TELEGRAM                         
  ▮  of the travel industry
    ⭐  ●Ann Thread ●Instagram   ⭐ 
✅    U.S.Sec    ➡️
✅  approved!  ➡️
Cyberdyne
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
May 07, 2013, 02:37:45 AM
 #7

This is the only thread on the entire forum that contains the word 'mincoind'.

Where does one get a copy of this for Windows? Smiley  Feeling very lame right now.
GSnak
Full Member
***
Offline Offline

Activity: 182
Merit: 100



View Profile
May 07, 2013, 02:40:13 AM
 #8

The trash bin.
Cyberdyne
Hero Member
*****
Offline Offline

Activity: 630
Merit: 500



View Profile
May 07, 2013, 02:51:42 AM
 #9

The trash bin.

I checked but all I found there was midget porn. (I delete that regularly).
manface
Full Member
***
Offline Offline

Activity: 126
Merit: 100


View Profile
May 07, 2013, 03:08:00 AM
 #10

All Bitcoin chains suffer from this same thing, its just easier to do in Mincoin. It doesn't harm the chain it just means more coins can be released faster over a period if the miner doing it has enough power. As the mining network grows this is more and more difficult to do like tacotime pointed out. Not a big deal at all.
Shad3dOne
Sr. Member
****
Offline Offline

Activity: 261
Merit: 250


Interesting.....


View Profile WWW
May 07, 2013, 03:23:13 AM
 #11

interesting...

Domain for sale -> NXTcoin.com, 200 btc/2.9 M nxt. pm me
like craigslist but for btc! --> Visit BTClist.com
FederationCredits--> C6khbXzADRUeT9di2SpNubCt2UVTuayKMV What's this?
TheSwede75
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 07, 2013, 04:34:49 AM
 #12

Why are we even discussing mincoin? Check first day block reward and diff and you have to be a lunatic to ever touch that shit. Block reward goes from 100/block to 2/block in 3 days ha ha..  'Developer' (and I am using the term loosely) must have been smoking fucking Meth when he threw that piece of dung out on the forum.
mc_lovin
Legendary
*
Offline Offline

Activity: 1190
Merit: 1000


www.bitcointrading.com


View Profile WWW
May 07, 2013, 04:40:59 AM
 #13

Why are we even discussing mincoin? Check first day block reward and diff and you have to be a lunatic to ever touch that shit. Block reward goes from 100/block to 2/block in 3 days ha ha..  'Developer' (and I am using the term loosely) must have been smoking fucking Meth when he threw that piece of dung out on the forum.

Yeah but look how much meth money he has now by selling his failcoins on noobs?
TheSwede75
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
May 07, 2013, 05:23:03 AM
 #14

Why are we even discussing mincoin? Check first day block reward and diff and you have to be a lunatic to ever touch that shit. Block reward goes from 100/block to 2/block in 3 days ha ha..  'Developer' (and I am using the term loosely) must have been smoking fucking Meth when he threw that piece of dung out on the forum.

Yeah but look how much meth money he has now by selling his failcoins on noobs?


If you want to giggle for a second, check out this screenshot of the 'mincoin mafia' (such cute kids) bragging about calling me out as a scammer and trying to discredit me on BTC-E:
https://i.imgur.com/UOYpl7B.png

Priceless! Altcoins - It's serious business Smiley
AzureEngineer
Member
**
Offline Offline

Activity: 98
Merit: 10



View Profile
May 07, 2013, 05:24:15 AM
 #15

MNC is changing the scheme from "Pump and Dump" to "Crash and Burn."

My name was simply a play on "Blue Engineer" from Team Fortress. I am not affiliated with Microsoft or the Azure project.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!