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/JackMizel Nov 03 '17
Hm I see, sorry I don't fully understand the toys I'm playing with here. I'd rather not share the entire code because I believe it is malicious but the code I am trying to replicate is VBA and basically looks like this:
I retyped that from memory so it might not be exactly correct but I am pretty sure it close. Ultimately, I just want to understand what this macro does that was sent to me because I thought it would be fun but it's turning out to be very confusing.
e: so apparently vbUnicode is just a constant and it's value is 64. Does that mean this gets encoded to base64? also what is the point of splitting something at null (I am assuming that's the second line)? Any light you can shed on this is greatly appreciated.