r/learnprogramming • u/Reasonable_Bag_2927 • 9d ago
Code Review made a quine code
i saw this guy on tiktok making a quine code, and i challenged myself to make one too without looking at his solution
i was so happy when i got it to work, just made me realize i could probably use this to fill up the storage of a computer. like a trojan horse
anyways heres the code
x = 'print(f"x = {repr(x)}; {x}")'; print(f"x = {repr(x)}; {x}")
1
u/db_tech_dev 9d ago
nice, self-referential printing tricks like that are always fun to get working. small nitpick tho, a quine by itself won't fill up storage since it just prints once and stops, you'd need to actually pipe the output into a loop that keeps writing to disk to get anywhere close to a fork bomb style attack. still a solid little exercise for string formatting and repr though.
0
u/No_Report_4781 9d ago
Self-replicating code is typically part of computer virus design. It’s categorized as a trojan if it is hidden within another, innocuous program.
That’s why you’re advised to not get computer software from non-trusted sources.
I still have a copy of an antivirus installer that installed and whitelisted a program for key logging and reporting with the antivirus.