/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?
[Bonus] Daily Programming Challenge!
How would you protect your program execution from attempts to inject arbitrary data into resident memory?

Other urls found in this thread:

eu.battle.net/forums/en/wow/topic/17611273110
en.cppreference.com/w/cpp/container/map/extract.
twitter.com/SFWRedditImages

>Created before the bump limit
>Doesn't follow OP format
Delete this invalid thread.

Too soon and picture unrelated to programming.

Sage and report.

>to inject arbitrary data into resident memory?
You dont have this problem with functional languages who are run-time safe.

there's nothing wrong with arbitary limits
the computer's memory is not infinite

>1 The implementation shall be able to translate and execute at least one program that contains at least one instance of every one of the following limits:
>[...]
>— 4095 characters in a logical source line

>injection
>unrelated to programming

>the computer's memory is not infinite
Doesn't mean you have to read the entire file into a buffer.

i was thinking keep a master checksum of every bit of data allocated to my program and then recalculating after any modifications, but what if they overwrite my checksum?

Pretty sure you meant to post in this thread:

fuck off with your facebook shit

>How would you protect your program execution from attempts to inject arbitrary data into resident memory?
By not being a dumbass about how I handle user input.

What if you're writing a game and you're trying to prevent cheating by simple means, like memory editing?

Anime is always related to programming.

Well, if it's single player, you don't give a fuck.

If it's single player and you have microtransactions for easymode, burn in a fire.

If it's not single player, do sanity tests server-side. "Is the player moving faster than the max speed given his situation?" Is he accelerating in the XZ axis despite not being on the ground?"

you can detect dll injections / memory access on windows somehow

This right here. For single player, the user has a right to cheat if they so feel like it... the only person screwed is themselves. For multiplayer, use the server. If it's hotseat multiplayer, the other guy in the room knows what's up.

I few years ago I downloaded some WoW cheating program which allowed me to run extremely fast. I just ran through the jungle with no one around but they detected it.

I wondered how they specifically managed to catch me. So what do they check every frame that every player is not flying or running faster than they should be?

>program crashes with library error on Linux Mint
>it runs fine on windows
windev here I come I guess

kill me

>everyone sees you running extremely fast
>hmmm i wonder if he's cheating??

Youre probably missing a random devlib

It was a low population server, I haven't come across anybody else and only used it for about 3 minutes out of curiosity.

maybe the server does sanity checks on clients doing things that shouldn't be possible, like running 9999999 speed or something

all the libraries came with the source code
it was already set up for qtcreator all I did on either system was load it into qtcreator
I think openJDK was fucking me somehow, because the program calls java for graphics and a console

what's weird is it was working fin on linux for a solid while, and then it just started having errors after I added some stuff to the code. Now, mind you, it gets through all of my code without error. it seems my additions somehow caused other parts unrelated of the code to behave differently and lead to the library error

Yeah that's one way. You don't technically do it every frame, just every time a packet comes in. Not even necessarily every time a packet comes in. You could do it on random packet receive events. WoW also has code injection detection too because some of the gameplay (herb picking; grinding; mining; excessive addon usage) is indistinguishable from using bots. But that should have been rectified by changing the gameplay desu.

Were you banned immediately? My understanding is that blizz bans in waves because they're shady assholes. Banning people in waves rather than immediately makes them more likely to buy the game again.

Fuck QT, get off that pajeet shit.

i have no choice in the matter

Please rate my D code Sup Forums-kun. I'm writing a discord bot.

Wow's a big fucking game. Even on a server with 3k people online, you could run around like desolace or the eastern coast of arathi highlands no problem. And in modern you can really cheat in the old content without people seeing since the old content is so empty.

Also you could cheat in an instanced dungeon and no one could see because you're the only one in it.

Provide a decent alternative to QML.

>Player reports being at position (x1, y1) at t1, and being at position (x2,y2) at t2.
>Server side sanity check: Is this possible?
>No
>Autoban

>Were you banned immediately?
Since this happened about a decade ago my memory of it is foggy. I was either disconnected from the server and banned, or the ban took effect after I logged out.
Either way it happened within about an hour. It was a short ban though, I believe 24 hours or some shit.

>Banning people in waves rather than immediately makes them more likely to buy the game again.
The fuck?

don't understand shit, but looks promissing

Ricers ladies and gentlemen.
>hurr install gnetoo xDddxD

I get that they do sanity checks, what I'm wondering is how exactly they do it and how frequently.

try to subdivide your code into simpler more understandable functions, will really help you read your own code in a year, each function should have ~20 lines max

Use selective imports.
dont brace one if / else statements.
Could probably de-pajeet your params length checks into a final switch.

Other than that it looks okay for the most part.

>Fuck QT,
why tho?
Clang static analyser, GDB, CMake, Visual Studio keybinds, optional Vim keybinds... etc.
I can't think of anything it could possibly be missing

its pretty lenient, you can get away with a certain ammount of speedhacking because the game doesn't want to punish players that are just lagging and not speedhacking.
The game wouldn't be popular if everyone with a bad connection got rubberbanded or booted.
That being said the detection isn't always accurate and it would often boot you if you charged right as the same time you got stunned. It would detect that you were moving while stunned and boot you. But other times you could see lagging players or hacked players moving around while stunned for the entire duration of the stun. The games pretty messy.
a quick google search says that the charge bug was still in the game in may 2016 lmao: eu.battle.net/forums/en/wow/topic/17611273110

bugs been in the game so long people started trying to time their spells to disconnect warriors on purpose. What a joke of a game

Its a bloated, buggy piece of shit.

Qt != QtCreator

I factored a bunch of the static checks out into helper templates but I hit a compiler bug so for now it has to stay in.

It creates this idea that you won't get necessarily banned, they just "caught you" at a later point in the future. So you just "got unlucky" or you were in the clear until you somehow "messed up" and need to try again, even though they immediately knew.

My understanding of this comes from a defcon panel about hacking videogames which alleges this.

But if it was a decade ago it was probably before blizz got bought out by activision.

ah, I see, yeah fuck QT5
shoo
QTCreator a best

Is "Where's Waldo?" decidable?

Oh kek. I wish I knew that when I played. Woulda been fun to turn hammer of justice into the hammer of warrior banishment.

>I hit a compiler bug
report that shit nibba

Nana and IUP are the only acceptable GUI libraries.
Poco, Boost and STL for the common stuff

>dont brace one if / else statements
this depends on what style guides hes following
some require braces around all if-s and else-s

What compiler you on, and what was the bug?

I made some cursory attempts to reduce it to a test case but I couldn't so I gave up.

That would be a question to ask a Blizzard employee, who would promptly tell you to fuck off.

Nana is complete garbage that gets stomped by QML, I'll look into IUP though, haven't heard of it before.

try out the different D compilers, there are a whole bunch dmd,ldc etc... to see if it really is compiler specific

>tfw the only compiler bug I've ever submitted was marked as resolved in the latest version, and I was told to stop using debian

kek

Well if youd look at the code, hes using it inconsistently for variables.

2.073.1 I think. It doesn't matter though because I updated to 2.075 which broke vibe.d, which my project depends on.

I don't have LDC/GDC installed. Maybe I'll try building with one of them eventually.

>D has more compilers than programmers

>I updated to 2.075 which broke vibe.d, which my project depends on.
Im taking a break from Vibe.d desu, ive had enough of diet templates for a lifetime.

I'm not saying he shouldn't be consistent, he definitely should
I'm just saying what he should be consistent -to- is ambiguous to us, and telling him to always un-brace single statement if-s and else-s is not necessarily good advice

What's wrong with diet templates compared to jade or some other template language?

I'm new at C++ and I'm having an idiotic problem. I have a map of objects to vectors of objects. (It's modelling a digraph: the keys are the nodes, the values - vectors of nodes - are the immediate descendant, so to speak, of the key node.) Now I want to iterate over this map and potentially change some of the fields of those objects.
Thing is, it turns out keys in maps are immutable. Wat do? I literally have no idea what the best approach would be.

As a simple example, imagine iterating over all the keys (i.e. nodes in the graph) and flipping a "traversed" flag on them to true. That sounds simple enough, but I don't know how to go about it.

Theres only three main ones. But GDC is basically irrelevant because LDC is for when your reference is good and you want your final compile for more optimizations.

>Oracle has more lawyers than programmers

3 compilers, 2 programmers total.
Marvellous.

I also recommend putting all those 'import $foo'
(import std.meta etc...) above at the top of your code, never in a function!

also for security reasons, try to avoid using global variables like the alias Response, plus if you want to really go hardcore sanitize all inputs so someone can't crash your bot with rare input

diversity is the spice of dlife

Map it to a different key? I don't get what your problem is.

Painfully slow to compile even when caching stripped down d code is awkward
The forced indention got old.
and for the life of me, i could not figure out why string interpolation would not work. I just want them to re-do it completely, and not base it off pug/jade.

>Never import in a function
>Global variables like alias Response
Not trying to be rude, but you've obviously never used D.

And then delete the old one? That seems messy. I could do it though.

caching,*

I see. If they get banned in batches though a group of cheaters would tell each other that they were also banned during the same time.

It would make the most sense to have a script that bans random people at random times once they've been added to a list.

make a vector aff all key
for example
vector mykeys = mymap.getkeys();
for (int i = 0; i < mykeys.size(); i++) {
vector = temp;
temp = mymap.get(mykeys[i]);
//do stuff with temp
}

should get every value from every key

local imports are a feature and encouraged idio in D
There are no globals in D, only module-scoped ones.

Yeah, or you can wait until C++17 is officially released and use en.cppreference.com/w/cpp/container/map/extract.

fug, wait

vector = temp;

should be
vector temp;

I don't think std::map has a getkeys() method though

std::vector extract_keys(std::map const& input_map) {
std::vector retval;
for (auto const& element : input_map) {
retval.push_back(element.first);
}
return retval;
}


and

std::vector extract_values(std::map const& input_map) {
std::vector retval;
for (auto const& element : input_map) {
retval.push_back(element.second);
}
return retval;
}

make a better map then
you can even use a std::map as a base and add that function
how hard could it be? kek

alternatively, there are implementations of maps in C++ that -do- have that as a function

Also, won't that fuck up the iterator? Will I need like a separate map to put my new elements into? If I delete the element from the old one it should be fine in memory usage, but it's still really messy and will have a whole ton of not-really-necessary copying.

Is there really no better way in C++11?

Would using a vector instead be a horrible idea?

defend this

It causes them to blame the person they bought the cheat from. So they'll try again with a different bot vendor. It's also grandstanding for optics with the honest playerbase.

>Also, won't that fuck up the iterator?
Only if you're modify the map while iterating over it.

One is simple and concise, the other one is convoluted and bloated.

One is a big book and the other is a booklet.

I'm trying to make a snake game.

can I just make a list of snake fragment objects where each fragment has the position of the fragment it is attached to in the last tick?

>just make a bunch of unnecessary copies temporary vectors
please stop giving advice

Element.first will still be const though, won't it?

...which I will, since you advised me to make a new element and delete the old one

>...which I will, since you advised me to make a new element and delete the old one
These operations do not involve looping. If you are however looping you'll have to re-retrieve the iterators after the operation.

Fug. I did say in my first post that I was looping and modifying practically every key (such as marking it as "traversed"), so I'm basically fucked. Yay!

>Programming language initially designed as an extension of another programming language has a larger book than said programming language
Does it really need defending? This should be obvious.

But someone who is not a Blizzard employee could make educated guesses. If there is a set of possibilities with good solutions there is a good chance that one of them is used by Blizzard.

...

the C section in the C++ book is bigger than all of K&R

>I did say in my first post that I was looping and modifying practically every key
I missed that bit but I feel like there's a better way to do whatever you're trying to do.

Why do in C/C++ what can be done in vanilla javascript?

>immutable strings
what did she mean by this?

I know, hence my question.

But in a stroke of unprecedented genius I decided that maybe using POINTERS to the objects as keys would be a good idea. This let's me modify the objects' fields while keeping my map intact. I think this is exactly what I was looking for.

>nuclear weapon launch systems will one day be running in node

>C and C++ will one day be unknown arcane magic known only by the old wizards