Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert binary (exe) to text and back again

134 views
Skip to first unread message

sumGirl

unread,
Sep 29, 2006, 8:43:20 AM9/29/06
to
Hi all. Sometime last year I ran across a script that allowed you to
use ADODB.Stream (I think) to convert an exe file into text and then
back to the exe if you wished. It was very useful for sending exe's in
emails or downloads to get around restrictions my company has on doing
such.

I have lost that script!!! Anyone know how to do this?

arpit....@gmail.com

unread,
Sep 29, 2006, 2:43:59 PM9/29/06
to
Hi
Simply change the extension of your file from .exe to .txt then again
change from .txt to .exe . This is a very useful trick to overcome
such hurdle .

sumGirl

unread,
Oct 18, 2006, 8:16:44 AM10/18/06
to
Do people get points or something for just posting stuff? I have a very
specific thing I wanted to do and asked about, I promise I would have
asked for suggestions if I wasnt sure about what I want to do. You
really think I would be considering such a technical option and it
never occurred to me that I can change a file extension? Really??? You
also think thats a 'useful trick' like you discovered something clever
and unique that no one ever thought of?

In a real environment you dont base file blocking on file
names/extensions...you base it on crc's and object headers so you catch
'clever people' like you trying to 'trick' the system.

On Sep 29, 2:43 pm, "arpit.pali...@gmail.com"

> > I have lost that script!!! Anyone know how to do this?- Hide quoted text -- Show quoted text -

mayayana

unread,
Oct 18, 2006, 9:27:22 AM10/18/06
to
I would have suggested the same as
arpit.paliwal. In most "real environments"
that I deal with, renaming an EXE to TXT
is sufficient.

I've never used ADODB, but since no one
else has answered your post.....

The only way I know to "convert binary to text"
is through Base64. That can be done in script
if you want that:
http://www.jsware.net/jsware/scripts.php3#bints

There is one catch, though: All binary files get
converted to Base64 when sent in email because
text is all that SMTP handles. So if you have an
especially nosey filter it may catch the file. If it were
me I'd try some kind of custom format, like may
add the Base64 equivalent of a BMP header to the
front of your file on the sending end, then when you
receive it just snip off those characters and convert
the rest of the string back to binary. Then your filter
will probably just think the file is a BMP.

Hopefully your nosey filter doesn't also do porn
image matching. In that case you'd have to also
make sure that you don't have any functions in your
EXE that happen to look like a nipple when the
bytes are part of a BMP. :)

Fosco

unread,
Oct 19, 2006, 2:33:42 AM10/19/06
to
"sumGirl"

I have not read your original post but only replies maybe
i mismatch but give a try to this from Cenati :

'************************************************
' File: HexDump2.vbs (VBScript)
' Author: Giovanni Cenati
' 16 june 2005
' Mostra in IE un file in esadecimale
' Shows a hex dump of a selected file
' http://digilander.libero.it
' Codice utilizzabile citando il sito.
' Based on a script post by spmlinton at sk sympatico ca
' in the newsgroup microsoft.public.scripting.vbscript
' on Thu, 27 Mar 2003
'************************************************
Set objArgs = WScript.Arguments 'Vedo se ci sono degli argomenti passati allo script
if objargs.count=0 then
Set comDlg=CreateObject("MSComDlg.CommonDialog.1")
const cdlOFNHideReadOnly = 4 'Nasconde la casella "sola lettura"
const cdlOFNFileMustExist = 4096 'Puoi scegliere solo files esistenti
Const cdlOFNExplorer = 524288 'Finestra in stile win95
comDlg.Flags = cdlOFNHideReadOnly + cdlOFNFileMustExist + cdlOFNExplorer
comDlg.Filter = "Tutti i files|*.*"
comDlg.DialogTitle="Visualizza un file in formato esadecimale"
'comDlg.InitDir="c:\"
comDlg.maxfilesize=500
'comDlg.FileName="c:\autoexec.bat"
comDlg.ShowOpen
if comDlg.FileName="" then wscript.quit
FName= comDlg.FileName
'Ricordo il filename scelto. Saves the filename in variable
set comDlg=nothing 'Scarica l'oggetto. Discards object
else
fName = objArgs(0)
end if

' Lancia Internet Explorer per mostrare i risultati.
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.navigate "about:blank" ' documento vuoto. Empty doc.
' Importante: aspetta che Internet Explorer sia pronto
Do While (oIE.Busy) ' Waits until IE is ready
WScript.Sleep 200 ' Sospende per 200 millisecondi.
Loop
oIE.Visible = 1 ' Internet Explorer č visibile.
oIE.ToolBar = 1 ' ed ha la toolbar cosě č presente il pulsante "stampa"
Set doc1 = oIE.Document ' Punta al documento...
doc1.open ' ...lo apre
' Scrive le intestazioni html. Writes html headers
doc1.writeln("<html><head><title>" & Title & "</title></head>")
doc1.writeln("<body bgcolor='#FAF0F0'><pre>")

Const ForReading = 1
set fso=createobject("scripting.filesystemobject")
set f=fso.getfile(FName) 'apro il file. Open file for reading
set ts=f.OpenAsTextStream(ForReading,0) 'in lettura
byteCtr=0
chCtr=0

doc1.writeln(Fname)
doc1.writeln(f.size & " bytes")
doc1.writeln()
do while not ts.atendofstream
ch=ts.read(1) 'Legge un carattere. Reads a char
chCtr=chCtr + 1 'E ne tiene nota nel conteggio. Counts it

hexch=hex(asc(ch)) 'Ne determina il codice ascii. Finds ascii code
if len(hexch)< 2 then hexch="0" & hexch
hexLine=hexLine & hexch & " " 'Adds it to the string

if asc(ch)> 31 and asc(ch)< 127 then 'Printable?
if ch=">" then ch="&gt;" '(IE lo interpreterebbe come un tag)
if ch="<" then ch="&lt;" '(IE would think it's a tag)
ascStr=ascStr & ch 'č stampabile. Yes
else
ascStr=ascStr & "." 'non č stampabile. No
end if

'Prepara la stampa di una riga:
'indirizzo - 16 esadecimali - 16 caratteri ascii
'Prepares a line to be displayed:
'Address, 16 hex characters, 16 ascii
if chCtr=16 or ts.atendofstream then
lineStr=byteCtr & vbtab & hexLine & vbtab & ascStr
'Now manages last line if it has less than 16 chars
if chCtr<16 then 'Se l'ultima riga ha meno di 16 cartteri...
lineStr=byteCtr & vbtab & hexLine 'inizio normalmente
for r= (chCtr+1) to 16 'poi riempio la parte restante della riga
lineStr= lineStr & "-- " 'con dei caratteri
next
lineStr = lineStr & vbtab & ascStr 'e finisco normalmente
end if
'Writes output to Internet Explorer
doc1.writeln(lineStr) 'Scrive in IE la riga creata
byteCtr=byteCtr + chCtr 'incrementa l'indirizzo
chCtr=0 'e azzera il parziale
ascStr=""
hexLine=""
end if
loop

'Chiude le intestazioni html
'Closes html headers
doc1.writeln("</pre></body></html>")
doc1.close

set fso=nothing
set f=nothing
set ts=nothing

--
Fosco

0 new messages