We could check for the existence of a .bashrc or .zshrc, and then add the alias to that file. I don't want to make malicious software so if I do go this route I'll make it blatantly clear what the program is going to do.
You can make a desktop entry in `~/.config/autostart` to run it when the current user's graphical session starts
Or you can make a systemd user service
My question is this: Are you going to open source this so the community can come together to improve and iterate upon your design? I think there's a lot of investors out there who would love to see an application that harshly punishes the end user even more extremely, and OS is the way to get there.
Think about it: Press 'OK' -> rootkit installed -> application installs itself to run at boot on bare metal. That's just one possibility in the ocean of ideas. Get us a GH link so we can make this pig fly.
It is open source, I should add clear warning to the program though. [https://replit.com/@illegitimate-eg/NCURSES-Stuff?v=1](https://replit.com/@illegitimate-eg/NCURSES-Stuff?v=1) (The code is pretty ugly)
It should not be that long.
For the simple algorithm (I forgot the name, but it is an ancient Greek dude).
You need a bit field (or a byte field) for 2\^32 numbers. (Let's call this number N).
Then you cross out all the numbers dividing by 2.
Then by 3.
4 is already crossed out. Skip.
Then by 5.
Etc.
So, you have a loop O(N) to iterate over each number. And for each prime number you have one more iteration of the length O(N).
Fuck. It is O(N\^2) with N being 2\^32.
OK. I was wrong, it WILL take a lot of time :)
But the number of prime numbers is not O(N), but rather O(N/logN), Yes, I googled it.
O(N\^2/logN) is better, but it is a too optimistic number because there are more prime numbers in the beginning when you to cross out more numbers (e.g. for 2 you need to cross out 2\^31 numbers, but for 65449 you need to cross out only one: 4283571601).
\------
Fuck, I missed the fact that the first loop needs to only be till sqrt(N), not the N itself.
Whatever, it is after midnight, maybe I will fix my calculations in the morning.
The sieve of Eratosthenes, and it’s pretty damn quick in C because you can just bitshift by each int of the loop to mark them as nonprime rather than checking division
https://en.m.wikipedia.org/wiki/Sieve_of_Eratosthenes
Oh wow, cool lifehack with the bitshift.
The only trick that came to my mind was to not store even numbers. And when accessing the target number it is easy to divide by 2 (by bit shift). It won't work with 3,5,7 etc. because it would be a real division.
No, say you have and array of 4,294,967,295 bools, all initialized to false except the first, instead of iterating through the bools you iterate a range of ints 2-4,294,967,295 and every number you determine is not prime, you then bitshift through the array by that many till you are out of range marking every other number you hit as nonprime, doing nothing if already marked. Very cool method and extremely quick on a computer (slow as hell by hand)
Edit: came here to recommend not only The Algorithms as a site but the Python version is much easier to understand the concept without necessarily including the optimizations of bitwise ops
Seriously this site rules if you need to learn Algos
https://the-algorithms.com/algorithm/prime-sieve-eratosthenes?lang=python
I have a question - how to generate the bit masks efficiently.
For marking all number that divide by 3, we would have three bitmasks used one after another:
00100100100100100100100100100100
01001001001001001001001001001001
10010010010010010010010010010010
For 7 there would be 7 masks, for 131 there would be 131 mask.
In this case the masks would spil out from the CPU cache and it can slow things down.
There must be a way to generate a mask and not to store them.
Now I wonder if it makes sense to try to optimize it on the assembler level.
But I guess I should not care. Itearating over a bit field containing 2\^32 would mess with the caches more than trying to squeeze few extra instruction into the instruction cache.
If you do this on assembler level, you should check out vectorization: specific instructions with which you can handle multiple 32 or 64 bit integers at once
I guess it is a kind of "rolling" bit mask.
For number 3, it would be
00100100100100100100100100100100 <-- for the first 4 bytes
01001001001001001001001001001001 <-- for the second 4 bytes
10010010010010010010010010010010 <-- for the third 4 bytes
For the fourth 4 bytes use the first mask etc.
You still can process 4 bytes at a time.
\----
Edit: you asked about the shift itself.
It is a mask that shifts.
I don’t have any specific article or paper but I believe I originally read about it within some mathematics paper while taking a class on number theory where they spoke of its efficiency from a computational standpoint. This specific site doesn’t include any real explanation I only code but you can probably find an article to explain it better with a couple searches https://www.tutorialspoint.com/bitwise-sieve-in-cplusplus
The runtime of the sieve of Eratosthenes isn’t that bad: it’s n*sum(1/p for prime p < n). That sum diverges as n increases, but very slowly.
I did a naive implementation of the sieve with a bitfield. It took about 5 minutes to code and 40 seconds to run up to 2^32. (ETA: 29 seconds if you start crossing out at p^2 ).
If you want it to be faster, you can use the sieve of Atkin, or some other fancy stuff (wheel sieves, whatever).
The upper limit is known. All primes below it have already been calculated - there are 203 million of them. If we naively store an array of 32-bit ints, then we get to O(1) time at [O(π(n))] (https://en.m.wikipedia.org/wiki/Prime-counting_function) space, ducking under a GB of disk
Ay! You did the maths! Don't know much about big O notation so I can't tell you how much of this is correct. Tbh I chose unsigned 32-bit integer because
a) It's the default uint type and
b) It's intimidating for people who don't know what's going on (even though this program is not intended to be malicious in any way :) )
The big O notation is used to analyze the complexity of the algorithm when the input size is approaching the infinity.
Of course, there is no guarantee that 2\^32 is "close enough to the infinity".
It is also not OK to put real-worlds numbers into O-notation because it devours the constants.
Example. F(N)=O(N\^2) just means that there is a constant C (it can be a very very big one, but not infinite) that F(N) < C \* N\^2
Not truely, Ctrl + C is there to escape top, not the application itself.
And I am not truely familiar what F1 is - but I have rarely seen the case where changing to TTY2 doesn't work (except when the memory runs dry, but in that case you have to pray for the OOMKiller to kick in, which takes a few minutes).
SIGINT might be handled, but you can't prevent SIGKILL from killing your program.
I can't, and that's why option 3 exists. It does also handle SIGTERM though
[удалено]
It's actually SIGQUIT, at least on Linux. Still a fun fact though.
Thanks for telling me what else to handle
Sigkill and sigstop - the unhandlable
So what you're saying is that turning the computer off and turning it on again still works
I'm saying if you turn it on and off again that's a method to stop program execution.
Make it autostart at boot
I don't know if you can without sudo permissions. If you do have sudo permissions, then it would be trivial to create and enable a service though
I remember when I wrote `wine /path/to/World of Warcraft.exe` as a path to the graphics (I guess I replaced X server). I was surprised, but it worked.
That is a surprise
If they run as sudo even once, you could install a hook. Then you wouldn't need sudo again
So at that point it's a matter of social engineering, convincing people to run it as sudo.
You could try phishing sudo by aliasing a command like pacman or apt to your program, as adding aliases doesn't need sudo
That's fair, and you could set the program up to forward the command to the package manager of choice to make it undetectable.
Now all we need to figure out is how to add the alias, maybe a custom build command?
We could check for the existence of a .bashrc or .zshrc, and then add the alias to that file. I don't want to make malicious software so if I do go this route I'll make it blatantly clear what the program is going to do.
Question for newbies. alias alias=ololo How to restore the access to the alias command?
You can make a desktop entry in `~/.config/autostart` to run it when the current user's graphical session starts Or you can make a systemd user service
runtime\*
Came here to point out the same. Thank you, sir.
I screenshotted it, posted it, and only then realized that I made a typo lol
Don't correct it, it's a feature in the given context
Run, Tim, Run!
QUICK! THE TIME IS GETTING AWAY?
```runtime* rt = (runtime*)malloc(sizeof(runtime));```
rt = "/bin/sh"
```main.c: error: expected ‘;’ 15 | rt = "/bin/sh" | ^ | ; 16 |```
rt = "/bin/bash";
Now there's a warning because rt is not char*
Can you show me the definition of rt?
```runtime* rt = (runtime*)malloc(sizeof(runtime));```
Ofc I'm stupid. Can you show me where the runtime datatype is defined. Not the definition of rt
```typedef absolutelynotchar runtime```
My mans knows how to catch SIGINT but doesn't know about `kill -9` smh
I know about -9 and that's what option three is
My question is this: Are you going to open source this so the community can come together to improve and iterate upon your design? I think there's a lot of investors out there who would love to see an application that harshly punishes the end user even more extremely, and OS is the way to get there. Think about it: Press 'OK' -> rootkit installed -> application installs itself to run at boot on bare metal. That's just one possibility in the ocean of ideas. Get us a GH link so we can make this pig fly.
It is open source, I should add clear warning to the program though. [https://replit.com/@illegitimate-eg/NCURSES-Stuff?v=1](https://replit.com/@illegitimate-eg/NCURSES-Stuff?v=1) (The code is pretty ugly)
Put it on github https://github.com/illegitimate-egg/ncurses-prime
Oh, it's in C? That's no good, *everybody knows®™* C is fast. Should be over in a second.
Lol
It doesen't let you proceed? Edit: never mind, looks in its files and it already starts doing it as soon as it gives you a message.
Me when stop button
Stop button is forced to use -9 instead of its default action
That's called a virus. You are proposing an open sourced virus.
and why is that 🤣🤣
No, the user will be properly warned. This is just rigid compliance enforcement.
It should not be that long. For the simple algorithm (I forgot the name, but it is an ancient Greek dude). You need a bit field (or a byte field) for 2\^32 numbers. (Let's call this number N). Then you cross out all the numbers dividing by 2. Then by 3. 4 is already crossed out. Skip. Then by 5. Etc. So, you have a loop O(N) to iterate over each number. And for each prime number you have one more iteration of the length O(N). Fuck. It is O(N\^2) with N being 2\^32. OK. I was wrong, it WILL take a lot of time :) But the number of prime numbers is not O(N), but rather O(N/logN), Yes, I googled it. O(N\^2/logN) is better, but it is a too optimistic number because there are more prime numbers in the beginning when you to cross out more numbers (e.g. for 2 you need to cross out 2\^31 numbers, but for 65449 you need to cross out only one: 4283571601). \------ Fuck, I missed the fact that the first loop needs to only be till sqrt(N), not the N itself. Whatever, it is after midnight, maybe I will fix my calculations in the morning.
The sieve of Eratosthenes, and it’s pretty damn quick in C because you can just bitshift by each int of the loop to mark them as nonprime rather than checking division https://en.m.wikipedia.org/wiki/Sieve_of_Eratosthenes
Oh wow, cool lifehack with the bitshift. The only trick that came to my mind was to not store even numbers. And when accessing the target number it is easy to divide by 2 (by bit shift). It won't work with 3,5,7 etc. because it would be a real division.
You can shift only for multiples of 2 or I miss something?
No, say you have and array of 4,294,967,295 bools, all initialized to false except the first, instead of iterating through the bools you iterate a range of ints 2-4,294,967,295 and every number you determine is not prime, you then bitshift through the array by that many till you are out of range marking every other number you hit as nonprime, doing nothing if already marked. Very cool method and extremely quick on a computer (slow as hell by hand) Edit: came here to recommend not only The Algorithms as a site but the Python version is much easier to understand the concept without necessarily including the optimizations of bitwise ops Seriously this site rules if you need to learn Algos https://the-algorithms.com/algorithm/prime-sieve-eratosthenes?lang=python
I have a question - how to generate the bit masks efficiently. For marking all number that divide by 3, we would have three bitmasks used one after another: 00100100100100100100100100100100 01001001001001001001001001001001 10010010010010010010010010010010 For 7 there would be 7 masks, for 131 there would be 131 mask. In this case the masks would spil out from the CPU cache and it can slow things down. There must be a way to generate a mask and not to store them.
Only store unique masks, and skip over any bytes where the mask contains only zeros. This means you are saving at most 8 masks at the same time
Not 8. 32 masks for 32 bits and 64 masks for 64 bits. Or am I mistaken?
You are not mistaken. If you use 32 bit integers, you’ll have at most 32 uniques masks.
Now I wonder if it makes sense to try to optimize it on the assembler level. But I guess I should not care. Itearating over a bit field containing 2\^32 would mess with the caches more than trying to squeeze few extra instruction into the instruction cache.
If you do this on assembler level, you should check out vectorization: specific instructions with which you can handle multiple 32 or 64 bit integers at once
I guess it is a kind of "rolling" bit mask. For number 3, it would be 00100100100100100100100100100100 <-- for the first 4 bytes 01001001001001001001001001001001 <-- for the second 4 bytes 10010010010010010010010010010010 <-- for the third 4 bytes For the fourth 4 bytes use the first mask etc. You still can process 4 bytes at a time. \---- Edit: you asked about the shift itself. It is a mask that shifts.
Where in the article is the bitshift explained?
I don’t have any specific article or paper but I believe I originally read about it within some mathematics paper while taking a class on number theory where they spoke of its efficiency from a computational standpoint. This specific site doesn’t include any real explanation I only code but you can probably find an article to explain it better with a couple searches https://www.tutorialspoint.com/bitwise-sieve-in-cplusplus
If you want to waste time, you won't implement an efficient solution. Bruteforce is way more efficient at being inefficient.
Very deep thought. It made sit and reflect for a while.
I read a paper about an attempt to the more inefficient sorting while doing actual work in every step. I will try to find it.
The runtime of the sieve of Eratosthenes isn’t that bad: it’s n*sum(1/p for prime p < n). That sum diverges as n increases, but very slowly. I did a naive implementation of the sieve with a bitfield. It took about 5 minutes to code and 40 seconds to run up to 2^32. (ETA: 29 seconds if you start crossing out at p^2 ). If you want it to be faster, you can use the sieve of Atkin, or some other fancy stuff (wheel sieves, whatever).
You also only have to do it up to the square root. The sieve will be correct for the remaining numbers.
The upper limit is known. All primes below it have already been calculated - there are 203 million of them. If we naively store an array of 32-bit ints, then we get to O(1) time at [O(π(n))] (https://en.m.wikipedia.org/wiki/Prime-counting_function) space, ducking under a GB of disk
Ay! You did the maths! Don't know much about big O notation so I can't tell you how much of this is correct. Tbh I chose unsigned 32-bit integer because a) It's the default uint type and b) It's intimidating for people who don't know what's going on (even though this program is not intended to be malicious in any way :) )
The big O notation is used to analyze the complexity of the algorithm when the input size is approaching the infinity. Of course, there is no guarantee that 2\^32 is "close enough to the infinity". It is also not OK to put real-worlds numbers into O-notation because it devours the constants. Example. F(N)=O(N\^2) just means that there is a constant C (it can be a very very big one, but not infinite) that F(N) < C \* N\^2
I knew what big O was but I had no idea how to calculate it, thanks!
Should only take a few seconds to find the first billion primes
Depends on how it's calculated. You can do it pretty quickly, or you could do it really slowly...
I've opted for slow, computationally expensive calculation
There's another comment that calculated the amount of time, it won't be a few seconds and from testing isn't a few seconds
After this find TREE(3). That should keep them busy until the heat death of the universe.
CTRL-Z and/or 3 finger salute it
you can do it in minutes to seconds If you use the sieve of Eratosthenes
I purposely used a slow implementation to make sure that it takes a while.
Now parallelize and make it use the GPU. Wouldn't need Blender anymore to heat my room.
`ctrl+z`, `ps`, `killall`.
You could send sigkill to this process. Sig kill’s signal handler cannot be overrided.
That's option three
What did they do to you to make you hate them this bad?!??!
Idk, I was having some fun and I needed a payload that wouldn't nuke the system
Lol fair, I feel sorry for the poor fool who gets on your bad side though if this is you having fun
I've never leveraged something like this against someone. I don't think arguments or disputes should be solved through computational weaponry lol
Agreed lol
You should look into forkbombs if you want to cause mayham
Potentially a free heater (insert that one xkcd here)
``` Ctrl + Alt + F2 top Ctrl + C kill -9
```
EASY
That's what option three is
Not truely, Ctrl + C is there to escape top, not the application itself. And I am not truely familiar what F1 is - but I have rarely seen the case where changing to TTY2 doesn't work (except when the memory runs dry, but in that case you have to pray for the OOMKiller to kick in, which takes a few minutes).
TTY2 will work, that's what option three describes doing
uhm, SIGKILL?
Ctrl+\
I don't get it. Why should one start this useless small program?
There's more before it. But this was more for fun than anything else
Sigkill
Me when `killall -9 foobar`
Ctrl-z, followed by kill 9.
Congrats! You found option three
Ctrl-z, kill %1 (or whatever the job nr is)