Skip to content

ValueError: invalid literal for int() with base 10: '1f' #1

Description

@jagernicolas

running the example from the readme,
https://github.com/danielfvm/memmod#examples
where I replaced supertux2 by a.out (see below)

by invoking the following command,
python3 test1.py
returns,

Traceback (most recent call last):
  File "/home/user/myenv/test1.py", line 7, in <module>
    puts = proc.get_libc_function("puts")
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 333, in get_libc_function
    func_addr = self.get_libc_function_addr(name)
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 325, in get_libc_function_addr
    libc = self.get_libc()
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 315, in get_libc
    self._libc = self._libc or self.find_module('libc.so') or self.find_module('libc-')
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 255, in find_module
    for m in self.modules:
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 89, in modules
    self.load_modules()
  File "/home/user/myenv/lib/python3.10/site-packages/memmod/process.py", line 193, in load_modules
    minor = int(device[1]),
ValueError: invalid literal for int() with base 10: '1f'

I'm interested by your pointer scanner. I tried a random test and got the same ValueError: invalid literal for int() with base 10: '1f'

about a.out, this is my dummy program I run to test memory hacking. I don't know if it's matter with the error above, so here the code (not clean or whatsoever),

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <thread>
#include <chrono>

class Gold {
public:
    int player1;

    Gold() : player1(0) {}
};

class Wood {
public:
    int player1;

    Wood() : player1(0) {}
};

class Resources {
public:
    Gold* gold;
    Wood* wood;

    Resources() : gold(new Gold()), wood(new Wood()) {}

    ~Resources() {
        delete gold;
        delete wood;
    }

    void sellWood(int value)
    {
        std::cout << "selling " << value << " units of wood." << std::endl;
        if(wood->player1 < value)
            return;

        wood -= value;
        gold += value;
    }
};

class World {
public:
    Resources* resources;

    World() : resources(new Resources()) {}

    ~World() {
        delete resources;
    }
};

int main() {
    // Seed the random number generator
    std::srand(std::time(nullptr)); // Removed static_cast<unsigned int>

    World world;

    while (true) {
        int goldIncrement = std::rand() % 1000;
        int woodIncrement = std::rand() % 1000;
        int woodToSell = std::rand() % 100;
        
        if (world.resources->wood->player1 < woodToSell && woodToSell < 50)
             world.resources->sellWood(woodToSell);

        world.resources->gold->player1 += goldIncrement;
        world.resources->wood->player1 += woodIncrement;

        if (world.resources->wood->player1 > 500) {
            world.resources->wood->player1 = 10;
        }

        if (world.resources->gold->player1 > 10000) {
            world.resources->gold->player1 = 0;
        }

        std::cout << "Gold: " << world.resources->gold->player1 << ", Wood: " << world.resources->wood->player1 << std::endl;

        std::this_thread::sleep_for(std::chrono::seconds(5));
    }

    return 0;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions