bap 18 Share Posted February 26, 2021 Hey! I wanted to have sort of 'human profiles' to my scripts so I decided to get into username hashing and that username hash is the seed for a random number generator then you can base your profiles off of that number and it will always be the same Code: private String username; private long seed; Random random; private int number; private boolean shouldGenerateHash = true; @Override public int onLoop() { if (shouldGenerateHash) { if (Players.localPlayer() != null) { username = Client.getUsername(); seed = UUID.nameUUIDFromBytes(username.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits(); random = new Random(seed); number = random.nextInt(); log("Random number based off of username: " + number); shouldGenerateHash = false; } } log("Done"); return Calculations.random(800,1150); } log("Random number based off of username: " + number); shouldGenerateHash = false; } log("Done"); return Calculations.random(800,1150); } Still trying to get a way to have the numbers a bit lower somewhere around the 10,000's as now it generates way above that. This is what I got from my test: 3:44:21 PM: [SCRIPT] Random number based off of username: 459183759 I'd like it to be in the 10,000's or at least in the 100,000's so it's a bit more manageable to generate profiles for. Hope you guys like this snippet and that it comes in handy Link to comment Share on other sites More sharing options...
Pandemic 2675 Share Posted February 26, 2021 You have to be really careful when generating random numbers, especially when using the same seed. You will always get the same "random" numbers in the exact same order every time you run something, which actually makes this example extremely detectable from a pattern detection perspective. What we do internally is a SHA-256 hash of the username, and we use that to set ranges and parameters that we use in conjunction with a standard, time based random so while the actions/timings are within a unique range per account but you're not getting the exact same result each time you run a script. To your question about getting a number within a set range, you can use the modulo operator, it returns the remainder of division: int randomNumber = 2009; int numberLessThan20 = randomNumber % 20; // The remainder of 2009 / 20, which is 9 in this case Link to comment Share on other sites More sharing options...
bap 18 Author Share Posted February 26, 2021 7 minutes ago, Pandemic said: You have to be really careful when generating random numbers, especially when using the same seed. You will always get the same "random" numbers in the exact same order every time you run something, which actually makes this example extremely detectable from a pattern detection perspective. What we do internally is a SHA-256 hash of the username, and we use that to set ranges and parameters that we use in conjunction with a standard, time based random so while the actions/timings are within a unique range per account but you're not getting the exact same result each time you run a script. To your question about getting a number within a set range, you can use the modulo operator, it returns the remainder of division: int randomNumber = 2009; int numberLessThan20 = randomNumber % 20; // The remainder of 2009 / 20, which is 9 in this case But humans aren't truly random, so wouldn't it make sense to keep a similar characteristic across bots? Link to comment Share on other sites More sharing options...
Pandemic 2675 Share Posted February 26, 2021 2 minutes ago, notsmile said: But humans aren't truly random, so wouldn't it make sense to keep a similar characteristic across bots? Yeah, that's why we set certain parameters and standard ranges per user and use that to help the normal time based random. If you use the "random" number you have up above, every time you use a Random with that same seed, you'll get the same outputs like this: // First script run sleep(random.nextInt(1000)); // 443 // Do something else Mouse.move(random.nextInt(400), random.nextInt(300)); // 101, 201 // Stop and re-run the script sleep(random.nextInt(1000)); // 443 // Do something else Mouse.move(random.nextInt(400), random.nextInt(300)); // 101, 201 // Forever Link to comment Share on other sites More sharing options...
bap 18 Author Share Posted February 26, 2021 Just now, Pandemic said: Yeah, that's why we set certain parameters and standard ranges per user and use that to help the normal time based random. If you use the "random" number you have up above, every time you use a Random with that same seed, you'll get the same outputs like this: // First script run sleep(random.nextInt(1000)); // 443 // Do something else Mouse.move(random.nextInt(400), random.nextInt(300)); // 101, 201 // Stop and re-run the script sleep(random.nextInt(1000)); // 443 // Do something else Mouse.move(random.nextInt(400), random.nextInt(300)); // 101, 201 // Forever Ah ok, that makes sense then. Hopefully I'll be able to improve on it! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.