Articles

Metasploit Framework Windows Tutorial
Remote Desktop Connection
Windows Processes That May Be Dangerous
How-To use NetCat a Tutorial
Common Linux Commands
Common Ports
Netcat Commands
HTTP Response Codes
War-Google Hack Terms
Wardriving
Avoiding Social Engineering and Phishing Attacks
Intrusion Detection on Linux
Linux Intrusion Detection
Penetration Testing Guide
Penetration Testing Tools
Social Engineering Fundamentals, Part I: Hacker Tactics
Social engineering (computer security)
The Psychology of Social Engineering

The Archives

General GSO
GovernmentSecurity.org News & Suggestions
In The News
Open Topic
General Security Information
Trash Can
Exploit & Vulnerability Mailing List Archives
Trial Member Forum
Product and Program Reviews GSO Tutorials
System Security
Windows Systems
Beginners Section
Linux & Unix Systems
File Downloads
Exploit Research & Discussion Trojan & Virus Errata
Networking Security / Firewall / IDS / VPN / Routers
System Hardening
E-Mail Security
Wifi Security
Trial Member Uploads
Upload discovered Trojans & Mal ware
GSO Programming Section
C , C++ , VC++
Visual Basic.NET
Perl /CGI
Java/Javascript
PHP/XML/ASP/HTML
Assembly + Other
The Cork Board
Network Security Consultant Directory
Network Security Jobs
The Archives
Encryption Information
General Network Security
Internet Anonymity
HTTP Protocol Security
Linux Security
MS IIS Information
Exploit Articles
Programming / Tool Design
GSO Software Projects
Public Downloads
Microsoft Security Questions and Papers

Full Version: Something2bat
ninar12
if seen the 2 exe someone other post

but ....

keep it scource biggrin.gif


CODE
 

/* by ninar1
exe2bat.cpp

main code taken from Riftor´s  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
aelphaeis_mangarae
What excactly does this program do?

Convert a batch to an exe?

Does it work?

A2_
QUOTE(aelphaeis_mangarae @ May 11 2005, 03:27 PM)
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.
realloader
Error...
It doesnt work.
bonarez
compiled ok on visual c++

can't convert exe's bigger then 64k:
CODE

File: unrar.exe to big 4 debug make sure FILE < 64KB
D:\_desktop\xplo\exe2bat\Debug>

works with ftp.exe
CODE

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
jeroen
here you go
compiled version!
Have fun

(put cygwin1.dll in the directory too)
THeGooDMaN
works well but only under 64kB :S
HMS
if(i>=65536)

*HINT*
jetprice
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).
Player
QUOTE(jetprice @ May 15 2005, 05:16 PM)
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?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2005 Invision Power Services, Inc.