Hack Forums
[C] What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? (/showthread.php?tid=6012969)



What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? - Tr0jandog - Oct 2, 2019

For doing stalling code, one way is to just use a for loop

but for example a for loop with 10k iteration doesnt generate 10k instructions and it is just based on inside of it


so what is the easiest way to actually make my stalling code produce 10k instructions other than copying some simple lines of codes thousands of times? any better way to do this?



BASICALLY i want to produce 10,000+ junk instructions, what is the easiest way to achieve this?


and yes i know there are better ways for stalling than this but I'm focused on this method right now


RE: What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? - HFDone - Oct 2, 2019

http://www.seclab.tuwien.ac.at/papers/acm_ccs11_hasten.pdf


RE: What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? - binbus - Oct 6, 2019

There is a public AI project that can generate code based off of open github repos


RE: What is the easiest way to produce 10k+ junk instructions from c++ code for stalling? - themayonnaiseguy - Oct 6, 2019

I've never really attempted any stalling, so forgive me if this is a silly suggestion. If you want to reproduce 10,000 of the same instruction in the disassembly, you could force it with preprocessor recursion:

PHP Code

<?php 
#define R10(x)  x;x;x;x;x;x;x;x;x;x
#define R100(x) R10(R10(x))
#define R10K(x) R100(R100(x))

R10K(test_function()); 

would for example, give

PHP Code

<?php 
0030229E  call        test_function 
(030145Bh)  
003022A3  call        test_function 
(030145Bh)  
003022A8  call        test_function 
(030145Bh)  
003022AD  call        test_function 
(030145Bh)  
003022B2  call        test_function 
(030145Bh)  
003022B7  call        test_function 
(030145Bh)  
003022BC  call        test_function 
(030145Bh)  
003022C1  call        test_function 
(030145Bh)  
003022C6  call        test_function 
(030145Bh)  
003022CB  call        test_function 
(030145Bh)  
003022D0  call        test_function 
(030145Bh)  
003022D5  call        test_function 
(030145Bh)  
003022DA  call        test_function 
(030145Bh)  
003022DF  call        test_function 
(030145Bh)  
003022E4  call        test_function 
(030145Bh)  
003022E9  call        test_function 
(030145Bh)  
003022EE  call        test_function 
(030145Bh)  
003022F3  call        test_function 
(030145Bh)
... 

But I'm not sure if this is of any use to you. Perhaps some of the other suggestions are the way to go! :)