
In this blog post, we will break down a smart contract exploit involving NORMIE tokens, which resulted in a loss of 224.98 ETH, worth approximately $881,686. The attacker used a series of strategic swaps, flash loans, and a vulnerability in the contract's logic to manipulate the token supply and gain significant profits. Let's dissect the steps and the code involved to understand how this exploit was executed.
1. Initial Swap and Balance Matching
The attacker initially swapped 2 ETH from the Sushi Router to obtain 171,955 NORMIE tokens.
They continued swapping tokens until they had roughly 5 million NORMIE tokens. The reason for accumulating 5 million tokens was to match the deployer wallet balance and bypass the premarketuser checks.

2. Manipulating the Premarket User List
The attack contract's address was added to the premarketuser list through the vulnerable getpremarket_user function. This function checks if the recipient address is not already a premarket user and if the amount being bought matches the team's wallet balance, granting premarket user status if both conditions are met.
By maintaining a balance equal to the team’s wallet, the attacker was added to this list.
function _transfer(address sender, address recipient, uint256 amount) private returns (bool) {
emit inSwapAndLiquifyStatus(inSwapAndLiquify);
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if (sender != owner() && recipient != owner()) require(enableTrading, "cannot trade before the market opening");
if (inSwapAndLiquify) {
return _basicTransfer(sender, recipient, amount);
} else {
if (!isTxLimitExempt[sender] && !isTxLimitExempt[recipient]) {
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
}
uint256 fAmount = (uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty))) % 11) + 90;
uint256 tokensToSwap = _minimumTokensBeforeSwap.mul(fAmount).div(100);
uint256 contractTokenBalance = balanceOf(address(this));
bool overMinimumTokenBalance = contractTokenBalance >= tokensToSwap;
emit stepLiquify(overMinimumTokenBalance, !inSwapAndLiquify, !isMarketPair[sender], swapAndLiquifyEnabled);
if (isMarketPair[sender] && !isExcludedFromFee[recipient] && premarket_user[recipient]) {
_balances[address(this)] = _balances[address(this)].add(amount);
}
if (overMinimumTokenBalance && !inSwapAndLiquify && !isMarketPair[sender] && swapAndLiquifyEnabled && !isExcludedFromFee[sender]) {
if (swapAndLiquifyByLimitOnly) contractTokenBalance = tokensToSwap;
swapAndLiquify(contractTokenBalance);
}
_balances[sender] = _balances[sender].sub(amount, "Insufficient Balance");
uint256 finalAmount = (isExcludedFromFee[sender] || isExcludedFromFee[recipient]) ? amount : takeFee(sender, recipient, amount);
if (checkWalletLimit && !isWalletLimitExempt[recipient]) require(balanceOf(recipient).add(finalAmount) <= _walletMax);
_balances[recipient] = _balances[recipient].add(finalAmount);
_get_premarket_user(recipient, amount);
emit Transfer(sender, recipient, finalAmount);
return true;
}
}3. Flash Loan and Token Swap
After becoming a premarketuser, the attacker took a flash loan of 11,333,141 NORMIE tokens.
They swapped 9,066,513 of these tokens for 65.97 ETH, significantly manipulating the token supply.
The remaining 2,266,628 NORMIE tokens were provided to the Uniswap V2 pair.
4. Exploiting the Swap and Liquify Mechanism
Using the skim function of the Uniswap factory, the attacker withdrew the manipulated assets.
The attacker’s contract, being recognized as a premarket user, triggered the minting of new NORMIE tokens.
5. Final Swap and Profit Extraction
The attacker swapped 0.5 ETH for approximately 11,040,494 NORMIE tokens at a lower price post-manipulation.
They repaid the borrowed NORMIE tokens, having inflated the token supply to 650 billion NORMIE tokens from an original 1 billion.
- The total profit amounted to 224.98 ETH, equivalent to approximately $881,686.
The swapAndLiquify Function
function swapAndLiquify(uint256 tAmount) private lockTheSwap {
uint256 tokensForLP = tAmount.mul(liquidityShare).div(totalDistributionShares).div(2);
uint256 tokensForSwap = tAmount.sub(tokensForLP);
swapTokensForEth(tokensForSwap);
uint256 amountReceived = address(this).balance;
emit eventSwapAndLiquify(amountReceived);
uint256 totalBNBFee = totalDistributionShares.sub(liquidityShare.div(2));
uint256 amountBNBLiquidity = amountReceived.mul(_liquidityShare).div(totalBNBFee).div(2);
uint256 amountBNBTeam = amountReceived.mul(_teamShare).div(totalBNBFee);
uint256 amountBNBMarketing = amountReceived.sub(amountBNBLiquidity).sub(amountBNBTeam);
emit teamGetBnb(amountBNBTeam);
emit marketingGetBnb(amountBNBMarketing);
emit liquidityGetBnb(amountBNBLiquidity);
if (amountBNBMarketing > 0) transferToAddressETH(teamWalletAddress, amountBNBMarketing);
if (amountBNBTeam > 0) transferToAddressETH(devWalletAddress, amountBNBTeam);
if (amountBNBLiquidity > 0 && tokensForLP > 0) addLiquidity(tokensForLP, amountBNBLiquidity);
}
This exploit highlights the critical importance of thoroughly auditing smart contract code to identify and mitigate vulnerabilities. The attacker's ability to manipulate the premarket user list and bypass liquidity checks resulted in a significant financial loss for the NORMIE token project. Ensuring robust security practices and regular audits can help prevent such exploits in the future.
Read more about Tsuru $410,000 Exploit
Author: Piyush shukla