Misc
Last updated
from pwn import *
def dfs(matrix , row, col, result): # vanilla dfs
global max_values
directions = [(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (-1, 1), (1, -1), (1, 1)]
rows, cols = len(matrix), len(matrix[0])
curr_val = matrix[row][col]
for dr, dc in directions:
newRow, newCol = row + dr, col + dc
if 0 <= newRow < rows and 0 <= newCol < cols:
new_val = matrix[newRow][newCol]
if(curr_val+1 == new_val):
result += new_val
dfs(matrix , newRow, newCol, result)
else:
if(result > max_values):
max_values = result
context.log_level = 'error'
while True:
r = remote("103.152.242.235", 26693)
for _ in range(10):
r.recvline()
zz = r.recvline()
print(_, zz)
if(b'sedih' in zz):
r.close()
break
rows = 50
cols = 50
matrix = []
for i in range(50):
matrix.append(list(map(int,r.recvline().strip().decode().split(' '))))
if(i == 0):
print(matrix[0])
max_values = -1
for i in range(rows):
for j in range(cols):
startRow, startCol = i, j
dfs(matrix, startRow, startCol, matrix[startRow][startCol])
r.sendline(str(max_values).encode())
# r.interactive()
from web3 import Web3
node_url = "https://eth-sepolia.g.alchemy.com/v2/SMfUKiFXRNaIsjRSccFuYCq8Q3QJgks8"
web3 = Web3(Web3.HTTPProvider(node_url))
abi = '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"getEverything","outputs":[{"internalType":"uint256","name":"otp","type":"uint256"},{"internalType":"string","name":"passphrase","type":"string"},{"internalType":"string","name":"decryptedFlag","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getIdentity","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOTP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPassphrase","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"help","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]'
caller = "0xF8dF23AFf40338c42aE9693f6242a0Ee24E5eDac"
private_key = "aff00a764af83a30cf3bcbb4667c5fcec6bf7830147b73b2b8b07d6ae09f60cc" # To sign the transaction
contract_address = "0x22420C6261054E5A5d5277fFcE0993D8223e5ccd"
contract = web3.eth.contract(address=contract_address, abi=abi)
print(contract.functions.help().call())
print(contract.functions.getEverything().call())