Converting hex or dec to ascii ?

Discussion in 'Ruby' started by mrpink, Apr 13, 2007.

  1. mrpink

    mrpink Guest

    Hi,
    I have a variable like:

    test = 0x65 0x78

    and I wanna have this converted or outputet to-----> ex

    which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
    this ?

    test = 0x65 doesn't, test = "0x65" doesn't test = String(0x65) also
    doesn't...

    can someone please help me with this?

    greets
    mrpink, Apr 13, 2007
    #1
    1. Advertising

  2. T24gNC8xMy8wNywgbXJwaW5rIDxhZG5hcmltQG1haWwucnU+IHdyb3RlOgo+IEhpLAo+IEkgaGF2
    ZSBhIHZhcmlhYmxlIGxpa2U6Cj4KPiB0ZXN0ID0gMHg2NSAweDc4Cj4KPiBhbmQgSSB3YW5uYSBo
    YXZlIHRoaXMgY29udmVydGVkIG9yIG91dHB1dGV0IHRvLS0tLS0+IGV4Cj4KPiB3aGljaCBpcyB0
    aGUgYXNjaWkgY29kZSBvZiAweDY1ICg9ZSkgYW5kIDB4NzggKD14KSAuIEJ1dCBob3cgY2FuIEkg
    ZG8KPiB0aGlzID8KPgo+IHRlc3QgPSAweDY1IGRvZXNuJ3QsIHRlc3QgPSAiMHg2NSIgZG9lc24n
    dCB0ZXN0ID0gU3RyaW5nKDB4NjUpIGFsc28KPiBkb2Vzbid0Li4uCgpJZiB5b3UgaGF2ZSB0aGlz
    IGluIGFuIGFycmF5LCB5b3UgY2FuIHVzZSBBcnJheSNwYWNrCgplZy4KCmEgPSAgWzB4NjUsIDB4
    NzhdLgphLnBhY2soIlUqIikKClRoaXMgd2lsbCB3b3JrIGZvciBtdWx0aWJ5dGUgdW5pY29kZSBz
    dHJpbmdzIGFzIHdlbGwuCgpIdGguCgotLSAKCuCkheCkreCkv+CknOClgOCkpAoKW3dyaXR0ZW4g
    aW4gaHR0cDovL3d3dy5wYWFoaWplbi5jb20vc2NyYXRjaHBhZF0KCltodHRwOi8vd3d3LnBhYWhp
    amVuLmNvbV0K
    Abhijit Gadgil, Apr 13, 2007
    #2
    1. Advertising

  3. On 13.04.2007 17:47, mrpink wrote:
    > Hi,
    > I have a variable like:
    >
    > test = 0x65 0x78


    What exactly is this supposed to mean? This is not valid Ruby:

    $ ruby -ce 'test = 0x65 0x78'
    -e:1: parse error, unexpected tINTEGER, expecting $

    > and I wanna have this converted or outputet to-----> ex
    >
    > which is the ascii code of 0x65 (=e) and 0x78 (=x) . But how can I do
    > this ?
    >
    > test = 0x65 doesn't, test = "0x65" doesn't test = String(0x65) also
    > doesn't...
    >
    > can someone please help me with this?


    Very likely, if we know what your input is.

    robert
    Robert Klemme, Apr 13, 2007
    #3
  4. mrpink

    mrpink Guest

    yeah this was wrong varibale too... but I got it out:


    shellcode = "\x65\x61"

    puts(shellcode)


    does what I needed :D
    mrpink, Apr 13, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    6,109
    Neredbojias
    Aug 19, 2005
  2. Replies:
    2
    Views:
    1,994
    Henri Sivonen
    May 28, 2005
  3. ^_^
    Replies:
    2
    Views:
    362
    Ben Pfaff
    Jan 6, 2004
  4. Bengt Richter
    Replies:
    6
    Views:
    439
    Juha Autero
    Aug 19, 2003
  5. J.E./C.Y.Cripps
    Replies:
    0
    Views:
    117
    J.E./C.Y.Cripps
    Dec 3, 2004
Loading...

Share This Page