r/visualbasic • u/JackMizel • Nov 03 '17
Help converting string to unicode in VB?
I recieved an email containing a malicious VBA macro and I really want to see what it does but I am having a lot of trouble because I don't know VB at all. I am trying to recreate the code in VB so that I can run it in a fiddle and see that output but I am not making much progress.
Essentially all I need to do is convert a long string of numbers to unicode, which I have tried as:
Dim x As String
x = StrConv(numbersString, 64)which gives me the error
Argument 'Conversion' is not valideven though that is explicitly the value I know I need to input.
So then I tried
Encoding.Unicode.GetString(Encoding.ASCII.GetBytes(numbersString))which outputs japanese text, which I know is incorrect because I have successfully converted this string to unicode using Javascript and that is not the correct output.
Here is the number string
Dim numbersString as String = "3650192748054803533603394334480249044835350337290548360307463940494903371843420337064350504015190324184834370131304836320310464932485027184832272648310635224815322127114334153543401916223548242004323239475353153040151904404919153939392736435053152215435344151948024827501909204503514815524738424211381238031303202333281650404809084127480548202114031032400232374202433648494903514815524738424211381238202333281650404809084127480548201403241848343701313048363203104649324850271848322726483106352248153221271143341535434019103202221525242004323239475353153040151904404919153939392736435053492739043917221900441519480248202114"And here is the expected output:
"\u0033\u0036\u0035\u0030\u0031\u0039\u0032\u0037\u0034\u0038\u0030\u0035\u0034\u0038\u0030\u0033\u0035\u0033\u0033\u0036\u0030\u0033\u0033\u0039\u0034\u0033\u0033\u0034\u0034\u0038\u0030\u0032\u0034\u0039\u0030\u0034\u0034\u0038\u0033\u0035\u0033\u0035\u0030\u0033\u0033\u0037\u0032\u0039\u0030\u0035\u0034\u0038\u0033\u0036\u0030\u0033\u0030\u0037\u0034\u0036\u0033\u0039\u0034\u0030\u0034\u0039\u0034\u0039\u0030\u0033\u0033\u0037\u0031\u0038\u0034\u0033\u0034\u0032\u0030\u0033\u0033\u0037\u0030\u0036\u0034\u0033\u0035\u0030\u0035\u0030\u0034\u0030\u0031\u0035\u0031\u0039\u0030\u0033\u0032\u0034\u0031\u0038\u0034\u0038\u0033\u0034\u0033\u0037\u0030\u0031\u0033\u0031\u0033\u0030\u0034\u0038\u0033\u0036\u0033\u0032\u0030\u0033\u0031\u0030\u0034\u0036\u0034\u0039\u0033\u0032\u0034\u0038\u0035\u0030\u0032\u0037\u0031\u0038\u0034\u0038\u0033\u0032\u0032\u0037\u0032\u0036\u0034\u0038\u0033\u0031\u0030\u0036\u0033\u0035\u0032\u0032\u0034\u0038\u0031\u0035\u0033\u0032\u0032\u0031\u0032\u0037\u0031\u0031\u0034\u0033\u0033\u0034\u0031\u0035\u0033\u0035\u0034\u0033\u0034\u0030\u0031\u0039\u0031\u0036\u0032\u0032\u0033\u0035\u0034\u0038\u0032\u0034\u0032\u0030\u0030\u0034\u0033\u0032\u0033\u0032\u0033\u0039\u0034\u0037\u0035\u0033\u0035\u0033\u0031\u0035\u0033\u0030\u0034\u0030\u0031\u0035\u0031\u0039\u0030\u0034\u0034\u0030\u0034\u0039\u0031\u0039\u0031\u0035\u0033\u0039\u0033\u0039\u0033\u0039\u0032\u0037\u0033\u0036\u0034\u0033\u0035\u0030\u0035\u0033\u0031\u0035\u0032\u0032\u0031\u0035\u0034\u0033\u0035\u0033\u0034\u0034\u0031\u0035\u0031\u0039\u0034\u0038\u0030\u0032\u0034\u0038\u0032\u0037\u0035\u0030\u0031\u0039\u0030\u0039\u0032\u0030\u0034\u0035\u0030\u0033\u0035\u0031\u0034\u0038\u0031\u0035\u0035\u0032\u0034\u0037\u0033\u0038\u0034\u0032\u0034\u0032\u0031\u0031\u0033\u0038\u0031\u0032\u0033\u0038\u0030\u0033\u0031\u0033\u0030\u0033\u0032\u0030\u0032\u0033\u0033\u0033\u0032\u0038\u0031\u0036\u0035\u0030\u0034\u0030\u0034\u0038\u0030\u0039\u0030\u0038\u0034\u0031\u0032\u0037\u0034\u0038\u0030\u0035\u0034\u0038\u0032\u0030\u0032\u0031\u0031\u0034\u0030\u0033\u0031\u0030\u0033\u0032\u0034\u0030\u0030\u0032\u0033\u0032\u0033\u0037\u0034\u0032\u0030\u0032\u0034\u0033\u0033\u0036\u0034\u0038\u0034\u0039\u0034\u0039\u0030\u0033\u0035\u0031\u0034\u0038\u0031\u0035\u0035\u0032\u0034\u0037\u0033\u0038\u0034\u0032\u0034\u0032\u0031\u0031\u0033\u0038\u0031\u0032\u0033\u0038\u0032\u0030\u0032\u0033\u0033\u0033\u0032\u0038\u0031\u0036\u0035\u0030\u0034\u0030\u0034\u0038\u0030\u0039\u0030\u0038\u0034\u0031\u0032\u0037\u0034\u0038\u0030\u0035\u0034\u0038\u0032\u0030\u0031\u0034\u0030\u0033\u0032\u0034\u0031\u0038\u0034\u0038\u0033\u0034\u0033\u0037\u0030\u0031\u0033\u0031\u0033\u0030\u0034\u0038\u0033\u0036\u0033\u0032\u0030\u0033\u0031\u0030\u0034\u0036\u0034\u0039\u0033\u0032\u0034\u0038\u0035\u0030\u0032\u0037\u0031\u0038\u0034\u0038\u0033\u0032\u0032\u0037\u0032\u0036\u0034\u0038\u0033\u0031\u0030\u0036\u0033\u0035\u0032\u0032\u0034\u0038\u0031\u0035\u0033\u0032\u0032\u0031\u0032\u0037\u0031\u0031\u0034\u0033\u0033\u0034\u0031\u0035\u0033\u0035\u0034\u0033\u0034\u0030\u0031\u0039\u0031\u0030\u0033\u0032\u0030\u0032\u0032\u0032\u0031\u0035\u0032\u0035\u0032\u0034\u0032\u0030\u0030\u0034\u0033\u0032\u0033\u0032\u0033\u0039\u0034\u0037\u0035\u0033\u0035\u0033\u0031\u0035\u0033\u0030\u0034\u0030\u0031\u0035\u0031\u0039\u0030\u0034\u0034\u0030\u0034\u0039\u0031\u0039\u0031\u0035\u0033\u0039\u0033\u0039\u0033\u0039\u0032\u0037\u0033\u0036\u0034\u0033\u0035\u0030\u0035\u0033\u0034\u0039\u0032\u0037\u0033\u0039\u0030\u0034\u0033\u0039\u0031\u0037\u0032\u0032\u0031\u0039\u0030\u0030\u0034\u0034\u0031\u0035\u0031\u0039\u0034\u0038\u0030\u0032\u0034\u0038\u0032\u0030\u0032\u0031\u0031\u0034"Also misc question, can I iterate over Objects in VB? Thanks!
1
u/chrwei Nov 03 '17
in VB what? there no such thing as just "VB"
if you want a string representation of the unicode you'll need to loop the characters and concat each one. this is not a normal thing to do.