Forums: Something2bat - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Something2bat here u go

#1 User is offline   ninar12 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 143
  • Joined: 07-September 04

Posted 11 May 2005 - 09:09 AM

if seen the 2 exe someone other post

but ....

keep it scource :D


 

/* by ninar1
exe2bat.cpp

main code taken from Riftors  exe2hex
	riftor@sec33.com
	http://home.graffiti.net/riftor615/

    so credits 2 him
  also thx 2 BCK


usage: exe2bat.exe [input.exe] [output.bat]


*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BEFORE "echo "   // piece before buffer
#define AFTER " >>123.hex" // piece after buffer
#define AFTER2 " >123.hex" // piece after buffer

char nfilein[128], nfileout[128],buffer[1];
FILE *filein, *fileout, *file;
int i;
unsigned char cbyte;
unsigned long cx, offset;


int main(int argc, char*argv[])
{

//usage      
if(argc!=3)
  {
   system( "cls" );
   printf("\n||exe2batch||\n",argv[0]);
   printf("\nUsage : %s inputfile outputfile",argv[0]);
   printf("\ne.g.  : %s dcmd.exe command.txt\n",argv[0]);
   exit(1);
  }
 
//checks for readaccess  
if ((filein= fopen(argv[1], "r")) == NULL )  
{
system( "cls" );
printf("\nFile: %s does not exist\n",argv[1]);
exit(1);
}
//BCK addon
//checks 4 filesize


char buffer[1];
file=fopen(argv[1],"r+b");
for(i=0;fread(buffer,1,1,file)!=0;i++);
if(i>=65536)
{
system( "cls" );
printf("\nFile: %s to big 4 debug make sure FILE < 64KB\n",argv[1]);
exit(1);
}



//do the job

        strcpy(nfilein,(const char *)argv[1]);
        strcpy(nfileout,(const char *)argv[2]);
        filein=fopen((const char *)nfilein,"rb");
        fileout=fopen((const char *)nfileout, "wt");
        offset=256;
        cx=0;
        fprintf(fileout,"%sn 1.dll%s",BEFORE,AFTER2);

        while(!feof(filein)){
                             fprintf(fileout,"\n%se %04x%s\n%s",BEFORE,offset,AFTER,BEFORE);
                             for(i=0;i<128;i++)
                             {
                                               fscanf(filein, "%c", &cbyte);
                                               if(feof(filein)){
                                                                break;
                                               }
                                               cx++;
                                               fprintf(fileout, "%02x ",cbyte);
                             }
        fprintf(fileout, "%s ",AFTER);
                             offset=offset+128;
        }
        fprintf(fileout,"\n%sr cx%s\n",BEFORE,AFTER);
        fprintf(fileout,"%s%04x%s\n",BEFORE,cx,AFTER);
        fprintf(fileout,"%sw%s\n",BEFORE,AFTER);
  fprintf(fileout,"%sq%s\n",BEFORE,AFTER);
        fprintf(fileout,"debug<123.hex\n");
  fprintf(fileout,"copy 1.dll %s\n",nfilein);
        fclose(filein);
        fclose(fileout);
  printf("\nFinished: %s > %s \n",argv[1],argv[2]);
        return 0;
}


sry 4 creating anew tread
0

#2 User is offline   aelphaeis_mangarae 

  • Members
  • Icon
  • Group: Members
  • Posts: 936
  • Joined: 22-January 04

Posted 11 May 2005 - 12:27 PM

What excactly does this program do?

Convert a batch to an exe?

Does it work?
:: Black Hat Forums ::
http://blackhat-forums.com
0

#3 User is offline   A2_ 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 34
  • Joined: 04-September 04

Posted 11 May 2005 - 02:18 PM

aelphaeis_mangarae, on May 11 2005, 03:27 PM, said:

What excactly does this program do?

Convert a batch to an exe?

Does it work?


no, it converts an exe to a batch script. just as "usage: exe2bat.exe [input.exe] [output.bat]" might be considered to imply.
0

#4 User is offline   realloader 

  • Corporal
  • Icon
  • Group: Members
  • Posts: 164
  • Joined: 05-December 03

Posted 12 May 2005 - 04:06 PM

Error...
It doesnt work.
0

#5 User is offline   bonarez 

  • Master Sergeant
  • Icon
  • Group: Specialist
  • Posts: 906
  • Joined: 17-March 04

Posted 12 May 2005 - 09:46 PM

compiled ok on visual c++

can't convert exe's bigger then 64k:
File: unrar.exe to big 4 debug make sure FILE < 64KB
D:\_desktop\xplo\exe2bat\Debug>

works with ftp.exe
D:\_desktop\xplo\exe2bat\Debug>exe2bat.exe FTP.EXE ftp.txt
Finished: FTP.EXE > ftp.txt
D:\_desktop\xplo\exe2bat\Debug>
rename ftp.txt ftp.bat
ftp.bat

....lots of code

D:\_desktop\xplo\exe2bat\Debug>copy 1.dll FTP.EXE
        1 bestand(en) gekopieerd.


and ftp.exe gets created again

works fine with me
Paraskavedeka Triaphoba
0

#6 User is offline   jeroen 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 62
  • Joined: 12-August 03

Posted 14 May 2005 - 09:02 PM

here you go
compiled version!
Have fun

(put cygwin1.dll in the directory too)

Attached File(s)


0

#7 User is offline   THeGooDMaN 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 42
  • Joined: 18-October 04

Posted 14 May 2005 - 09:49 PM

works well but only under 64kB :S
0

#8 User is offline   HMS 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 39
  • Joined: 14-February 04

Posted 15 May 2005 - 07:46 AM

if(i>=65536)

*HINT*
0

#9 User is offline   jetprice 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 89
  • Joined: 17-October 03

Posted 15 May 2005 - 09:16 AM

It is impossible to make a bat from a .exe, only the output of the program can be converted to .bat.

and to fix the 64kb file size do this:

if (i>=sizeof(unsigned long))

that should bring up the size to a reasonable size, still not big enough then consider using a long double.

Ok after reading the entire source code i see that you are using system("debug<123.hex"); It would be useless to use bigger size as the comment written by the author is correct (debug cant handle files bigger than 64kb).
0

#10 User is offline   Player 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 65
  • Joined: 08-February 04

Posted 16 May 2005 - 02:32 PM

jetprice, on May 15 2005, 05:16 PM, said:

It is impossible to make a bat from a .exe, only the output of the program can be converted to .bat.

That's what I was thinking too. So, this just works for exes that were originally bat?
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  • Share



Our Sponsors:


SwiftLayer Affiliate Web Hosting