Obfuscated code in C and what does this program code [closed] - c
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I need help please about this obfuscated code, what does this do?, What methods or programs should I use to get conclusion?
If you can give me examples of obfuscating methods that were used by the author of the programs code, I would appreciate it.
It is really difficult to know what this code dose but I can say maybe for data security. Any one can help me with this code please.
#include <stdio.h>
#include <math.h>
#define E return
#define S for
char*J="LJFFF%7544x^H^XXHZZXHZ]]2#( ###DA#(.##%(0CAaIqDCI$IDEH%P#T#qL%PEaIpBJCA\
I%KBPBEP%CBPEaIqBAI%CAaIqBqDAI%U#PE%AAaIqBcDAI%ACaIaCqDCI%(aHCcIpBBH%E#aIqBAI%A\
AaIqB%AAaIqBEH%AAPBaIqB%PCDHxL%H#hIcBBI%E#qJBH#C##D%aIBI#D%E#QB2P#E#'C#qJBHqJBH\
%C#qJBH%AAaIqBAI%C#cJ%" "cJ" "CH%C#qJ%aIqB1I%PCDI`I%BAaICH%KH+#'JH+#KP*#%S#\
3P%H#ABhIaBBI%P#S#PC#", *j ,*e;typedef float x;x U(x a){E a<0?0:a>1?1:a; }
typedef struct{x c,a,t; } y;y W={1,1,1},Z={0,0,0},B[99],P,C,M,N,K,p,s,d,h
;y G(x t,x a,x c){K.c=t ; K.t=c; K.a=a;E K;}int T=-1,b=0,r,F=-111,(*m)(i\
nt)=putchar,X=40,z=5,o, a, c,t=0 ,n,R;y A(y a,y b,x c){E G(a.c+b.c*c,a.a
+c*b.a,b.t*c+a.t);}x H= .5,Y =.66 ,I,l=0,q,w,u,i,g;x O(y a,y b){E q=a.t*
b.t+b.c*a.c+a.a*b.a;}x Q(){E A(P,M,T ),O(K,K)<I?C=M,I=q:0;}y V(y a){E A(Z,
a,pow(O(a,a),-H));}x D(y p){S(I=X,P =p,b=T; M=B[++b],p=B[M.c+=8.8-l*.45,
++b],b<=r;Q())M=p.t?q =M_PI*H,w=atan2( P.a-M.a,P.c-M.c) /q,o=p.c-2,a=p.a+1,t=
o+a,w=q*(w>t+H*a?o: w>t?t:w<o-H*a?t :w<o?o:w),A( M,G(cos(w),sin(w),0),
1):A(M,p,U(O(A(P,M,T) ,p)/O(p,p))); M=P;M.a=- .9;o=P.c/8+8;o^=a=P.t
/8+8; M=Q ()?o&1 ?G(Y,0,0):W :G(Y,Y,1);E sqrt (I)-.45;}
int main( int L,char **k){ S(e =L>1?1[z= 0, k]:J ;*e &&l<24 ;
++e)S(o=a =0,j =J+9;(c= *++j)&& !(o&&c< X&&(q=l+=w) );o ?o=*j++/
32,b++[B] =G(q +=*j/8&3,* j&7,0 ),B[r =b++]=G((c/8& 3)*( o<2?
T:1), (c& 7)+ 1e-4,o>2),1: (o =(a =(c-=X)<0?w=c+6 ,t= a+1:c?(t
?0:m(c),a ):*++j)==((*e|32 ) ^z)&&1[j]-X));S(z =3*( L<3);++
F<110;)S(L=-301;p=Z,++L<300;m( p.c),m(p.a),m(p.t))S(c=T;++c<=z;)S(h
=G(-4,4.6,29),d=V(A(A(A(Z,V(G(5,0 ,2)),L+L+c/2),V(G(2,-73,0)),F+F+c%2),G
(30.75,-6,-75),20)),g=R=255-(n=z)*64; R*n+R;g*=H){S(u=i=R=0;!R&&94>(u+=i=D(h=
A(h,d,i)));R=i<.01);S(N=V(A(P,C, T)),q=d.t*d.t,s=M,u=1;++i<6*R;u-=
U(i/3-D(A(h,N,i/3)))/pow( 2,i));s=R?i=pow(U(O(N,V(A(
M=V(G(T,1,2)),d,T)))) ,X),p=A(p,W,g*i),u*=U(
O(N,M))*H*Y+Y,g*= n--?Y-Y*i:1-i,s:G(
q,q,1); p=A(p,s ,g*u);h=A(h,N,.1
);d=A(d,N,-2*O (d,N));}E 0;}
This is an obfuscated, miniature Raytracing program.
It is described on site https://mzucker.github.io/2016/08/03/miniray.html
I found it by taking part of the mystery string "LJFFF%7544x^H^XXHZZXHZ", and googling for it.
If you run the compiled program and capture the output, you get a raytraced picture in .PPM format:
a.out > output.ppm
When I tried to run the program using a Visual Studio / Microsoft toolchain, this is what I got:
When I ran the same program on Linux/GCC, I got this image:
A bit more work, and I got this out of it:
.\a.out abelenky > abelenky.ppm
One of pictures I posted above came via a Visual Studio / Microsoft toolchain, and has obvious corruption in the bottom third of the image, as well as the checkerboard being green (it is supposed to be red).
I ran the same code via GCC on Linux, and the images came out perfectly.
I'm not sure where the difference comes from, but this helps illustrate how obfuscated code like this can highlight differences between Toolchains, Compilers, Operating Systems, etc, and proves why code like this has value.
I'm really disappointed that "user129..." thinks this is of no use in programming. It is one of the most advanced, award winning, obfuscated programs ever written. The techniques used to both develop the program and to obfuscate it are discussed in some detail on the github page and linked resources. It stretches C and graphics algorithms to the limits in some amazing ways.
This should be preserved and studied. Not mocked and closed.
Related
How do i clear this issue? unable to compile? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question got this error 11.43.36 JOB05184 $HASP165 IBMUSERX ENDED AT N1 MAXCC=12 CN(INTERNAL) IEW2735S DA0F OUTPUT DATA SET FOR DDNAME SYSLMOD HAS INVALID RECORD FORMAT. R IEW2008I 0F03 PROCESSING COMPLETED. RETURN CODE = 12. THIS IS MY CODE TO COMPILE:- //IBMUSERX JOB '285','POLSANI',NOTIFY=&SYSUID,REGION=6M //JOBPROC JCLLIB ORDER=S1304.ANIL.PROC //COBCL EXEC COBCL,MEM=HELLPGM1 //COMPILE.SYSIN DD DSN=IBMUSER.RKSH.COBOL(&MEM),DISP=SHR //LKED.SYSLMOD DD DSN=IBMUSER.RKSH.LOAD(&MEM),DISP=SHR PLEASE SOLVE THIS.
No one here can see what program is really being executed in the LKED step for which you have the SYSLMOD override, but it's probably IEWL (the binder, known in ancient times as the Linkage Editor). No one here can see what the attributes of your IBMUSER.RKSH.LOAD dataset are, but it must have RECFM=U. No one here can see which compiler you are using, but from your dataset names it appears you are compiling a COBOL program. If you are using a COBOL compiler version later than 4.2.1 your IBMUSER.RKSH.LOAD dataset must be a PDSE (not a PDS). If you are using a version of IBM Enterprise COBOL 4.2.1 or earlier, then your IBMUSER.RKSH.LOAD dataset can be either a PDS or a PDSE. Your compile listing includes which version of the compiler is being invoked. Your override... //LKED.SYSLMOD DD DSN=IBMUSER.RKSH.LOAD(&MEM),DISP=SHR ...should not specify a member name. It should look like this... //LKED.SYSLMOD DD DSN=IBMUSER.RKSH.LOAD,DISP=SHR Documentation for IBM Enterprise COBOL is available here. Documentation for the binder is available here.
Gets command error and gets_s command error [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago. Improve this question I have just started to learn File I/O in C Programming. However, I tried to make my own project which is used to read a created file. Now that I have written my code below could you please find the error and tell me what is wrong. The compiler does not show any kind of error but also it won't run, the compiler just blinks and then quits. I am using visual studio 2015 for my code: #include <stdio.h> int main(void) { FILE *fPointer; fPointer=fopen("Database.txt","r"); char text[150]; while(!feof(fPointer)) { fgets(text,150,fPointer); puts(text); } fclose(fPointer); return 0; }
I'm guessing you have a Console project in Visual Studio, and you're running it by hitting the Debug button (green triangle) or F5. A black console window flashes briefly onto the screen and then vanishes. This is normal. :-) You are running your code, and it's finishing, and the console window that it runs in is going away when it quits. To work around this "feature" of Visual Studio, put a breakpoint on the final return statement in main() (put the cursor on that line and press F9). Then the program will pause at that line, the console window will still be visible, and you'll be able to see your output. (Alternatively, don't run it from within Visual Studio, but open a Command Prompt and run it from in there. But I'd advise against this, because running it in the debugger is so much more useful.)
Including hidpi.h in WDK Driver Causes Compilation Errors
I'm trying to modify the KMDF vhidmini2 sample from the Windows driver samples on Github (https://github.com/Microsoft/Windows-driver-samples/tree/97cf8edcaddff4fdbc5cc48d56b7d7eb2c39b749/hid/vhidmini2). One of my modifications requires including the hidpi.h header file. When I do this, however, I get compiler errors, the majority of which are: identifier "USAGE" is undefined along with a couple of: redefinition: different type modifiers as well as a number of syntax errors. To try and seclude the error, I've tried compiling the vhidmini2 driver (which worked fine), and then inserting the include statement in the vhidmini.h file (which then causes the compilation to fail). Here's the include section of my modified vhidmini.h file; the rest of the code is untouched. #ifdef _KERNEL_MODE #include <ntddk.h> #else #include <windows.h> #endif #include <wdf.h> #include <hidport.h> // located in $(DDK_INC_PATH)/wdm #include <Hidpi.h> #include "common.h" As an aside, I found a similar problem posted to Stack Overflow here: WDK (Windows Driver Kit) and VC++ headers problem. The solution to this problem seemed to be to tell Visual Studio to load WDK headers before loading SDK headers. The question is a few years old though, and Visual Studio 2015 does not allow the editing of VC++ Directories in the same way. If this is indeed the solution to my problem, how would one go about making this edit in the new Visual Studio? I've tried looking at the property sheets for the project, but the format is completely different.
I managed to fix the problem by replacing the line #include <Hidpi.h> with #include <hidsdi.h> My guess (based off of a similar problem answered here: Compile error in 'winbase.h') is that hidsdi.h includes in it some things that hidpi.h requires. Therefore, you should either include hidsdi.h before hidpi.h, or only include hidsdi.h. This still seems odd to me though, since the Windows documentation for the structure that I'm using (HIDP_PREPARSED_DATA) says that I only have to include hidpi.h; I wouldn't be surprised if this was a typo (wouldn't be the first time I've seen a typo in the Windows documentation).
How to decode the c source code which is gcc compiled [duplicate]
This question already has answers here: How can I view the C code after compilation in binary code? (5 answers) Closed 7 years ago. I accidentally deleted my source program, now i only have the gcc compiled code.Is there any way to get back my source code.
Recovering C source from a binary has been described as "turning hamburger back into cows". You will not be able to recover your original source code. At best, you will get back some code that's functionally equivalent to your original source, but it won't contain any of your original variable names, comments, macros, etc., it may not be structured the same (depending on how aggressively it was optimized), and it may not be very understandable (again, depending on how it was optimized). Hopefully the original is still recoverable somehow.
You can use a disassembler, but you'll never be able to fully restore the program's source code. To prevent this in the future, I recommend either using source control, like Git or Subversion. Using these tools, you will always have backups of your code in case a big mistake like this were to happen.
If you are using an Eclipse-based IDE, it might have a saved version of your source in its history. If so, right-click on the project and select "Restore from Local History...". EDIT Otherwise try grep -a -C 200 -F 'Unique string in text file' /dev/sda1 > OutputFile; replace 200 with the number of lines you think are in the file and /dev/sda1 with the partition. See the Text file recovery section at https://wiki.archlinux.org/index.php/File_recovery for more info. Good luck!
How do I run a C program from my Windows command prompt? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 8 years ago. Improve this question Using Vim as an editor, I wrote the following simple code in C and saved it as helloworld.c : #include <stdio.h> int main(void) { printf("Hello world!\n"); } In command prompt, I wrote: start chrome helloworld.c This caused my browser to open up the file, but it did not print Hello World. Instead, it just displayed the code I had written. Did I not save it as a C file? Also, I was wondering how to display the result of my C program inline on command prompt, as I am fairly new to it. While searching the internet, I could not find any answers. Am I supposed to do so from Vim? I learned that you are supposed to do ./ in the gedit command box to display the result inline, but this does not work for the one that comes with Windows. Please help and thank you for taking the time to read and answer.
As #Ernest Friedman-Hill has already said, you normally have to compile the program. However, there are alternatives. One alternative is the Tiny C Compiler, from http://bellard.org/tcc/. TCC does allow you to run the program without compiling it. tcc -run helloworld.c Does exactly what you want. The Tiny C Compiler is not the only way to run C code from source without compiling it first. There are a few other alternatives. CSL: http://csl.sourceforge.net/csl.html Ch: https://www.softintegration.com/ PicoC: https://code.google.com/p/picoc/ CINT: http://root.cern.ch/drupal/content/cint I hope this helps.