JAxH obfuscated method, not text [closed]

A JAPH is a grand tradition of making a program that prints "Just another Perl hacker,". We already have a question about JAPH on this site but they seem more concerned with hiding the text, but JAPH has always been more about hiding the method by which it does what it does. Therefore I challenge you to show off your favorite language's cool features, and don't worry too much about hiding the text (unless you want to).

Here's mine, in Perl, which shouldn't be to hard for an experienced velociraptor to understand, but may be interesting for others.

C

Must be compiled to 32bit. On 64bit machines use gcc -m32 or such.

#include <stdlib.h>

int main() {
char *c = "echo Just another C hacker";
int foo=123; //unused                          /* Warning: there's a
int k=(int)1                                    * (long) system
//now for the fun part!                         * of chinese boxes
//behold:                                       * in this code. */
+0;
-1;
((int(*)(char *))k)(c);
}


Disclaimer: not my idea. I found it years ago hidden in some piece of code. Seriously. Theirs was even better, I forgot several little details. But the gist is there.

When you see it, you'll sh*t bricks.

• What the...? Can you explain how/why this works? – arshajii Jul 27 '13 at 15:07
• HA! @arshajii, it's all smoke and mirrors. I don't want to explain it away here, but read the code more closely. – breadbox Jul 27 '13 at 16:07
• ... That's fairly horrible. +1 – Hasturkun Jul 28 '13 at 11:52
• @Hasturkun Thanks. I did strive for the worst. For a moment I considered putting an "rm -rf ~" somewhere, but it'd have been unkind ;-) – Tobia Jul 29 '13 at 9:59
• @bread Ah! The /* is commented out! facepalm :-P – Doorknob Dec 24 '13 at 4:13

Mathematica:

TextRecognize@
ImageAssemble@
Transpose@
ImagePartition[Import@"http://i.stack.imgur.com/S9fci.png", 5]


Dart

class Print{
var PrinT,print,prinT;
get PRint() => PrinT;
get pRInt() => 'A$prinT'; get pRint() => print; set pRInt(PrinT){print=PrinT;} set prInt(pRInt){prinT='n$pRInt';}
Print(prinT,PRINT){
PrinT = prinT;
prInt = PRINT;
}
PRINT(print,PrinT){
pRint.PRint('$print${pRint.pRInt} $PRint$PrinT');
}
Print.print(print,prinT){
pRInt = new Print(print,'other');
PrinT = prinT;
}
}
main(){
Print print = new Print.print(print,'Dart');
print.PRINT('Just','Hacker');
}


Edit : less boring setter, less boring getter.

I have studied this language for a day, so I think other people may think this as a child's mess... :(

• props for early adoption, I will bend my rules and vote you up. Lets see what the judges (community) thinks – Joel Berger Oct 12 '11 at 3:23
• I agree with Joel. – DocMax Oct 15 '11 at 6:48

PRNG

It's in C, but it actually shows off that you can do cool things using PRNGs and outputs Just another PRNG hacker:

#include <stdio.h>

#define P 0x3A4B5C6D

char s[6];
int j, t;

void r(int d) {
t = ((P * d + P) << 17) + ((P * d - P) >> 15) + P;
for (j = 0; j < 5; j++) {
s[j] = (t % 51) + 67;
t /= 51;
if ((s[j] >= 91) && (s[j] <= 96)) s[j] = 32;
}
printf("%s", s);
}

int main() {
r(0x444C725);
r(0x2D65DD4B);
r(0x6C5C71A);
r(0xB2A4BBD);
r(0x275BD6F);
return 0;
}


Using the built-in PRNG (srand, rand) would be possible, too, but less portable.

• WOW. what... I... oh man – TehShrike Oct 30 '11 at 11:49

C

int main(int _)
{
putchar(~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(~-~-~-~-~-~-
putchar(-~-~-~-~-~-~-~-~
putchar(-~-~
putchar(~-~-~-~-~-~-~-
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(~-~-~-
putchar(~-~-~-~-~-~-~-~-~-~-~-~-
putchar(-~-~-~-~-~
putchar(-~
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
putchar(-~
putchar(~-~-
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
putchar(-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~_
))))))))))))))))))))));
}


Python

credits.__class__(0,'Just another Python hacker')()

• The method, of couse – etuardu Mar 13 '18 at 12:40

Javascript

eval('Acy419yt=12-14;'.split('').map(function(x){return String.fromCharCode(
0240-x.charCodeAt(0))}).join(''))[_]((___='splitulengthureverseujoinufilter'
.split('\x75'),function __(_){return _[___[1]]?__(_[___[0][0]+___[___[3]](''
)[___[0]]('')[___[4]](function(_,__){return ~~(__/2)==1})[___[3]]('')+'ce'](
1))+_[0]:_}("Just Another JavaScript Hacker"))[___[0]]('')[___[2]]()[___[3]](''));


In my code, JAJSH text was encrypted by reversing it, not only once, but twice!! Ha! Can you find it?

I did this one with some help.

{-# LANGUAGE ForeignFunctionInterface #-}

import Control.Applicative
import Foreign
import Foreign.C

foreign import ccall "stdio.h puts"
puts :: CString -> IO ()

main :: IO ()
main = liftM2 allocaBytes length
((<*> puts) . ((>>) .) . flip (flip zipWithM_ [0..] . pokeElemOff))
$map (fromIntegral . fromEnum) "Just another Haskell hacker\0"  And just for fun: {-# LANGUAGE ForeignFunctionInterface #-} import Control.Exception import Control.Monad import Data.Bits import Data.Word import Foreign import Foreign.C foreign import ccall "stdlib.h realloc" c_realloc :: Ptr a -> CSize -> IO (Ptr a) foreign import ccall "stdlib.h free" c_free :: Ptr a -> IO () foreign import ccall "stdio.h puts" c_puts :: CString -> IO () -- | Write a UTF-8 character into a buffer. -- -- Return the length of the character in bytes, which will be a number from 1-4. pokeUtf8 :: Ptr Word8 -> Char -> IO Int pokeUtf8 ptr char = case (fromIntegral . fromEnum) char :: Word32 of c | c <= 0x7F -> do put ptr c return 1 c | c <= 0x7FF -> do put ptr (0xC0 .|. c shiftR 6) put (ptr plusPtr 1) (0x80 .|. c .&. 0x3F) return 2 c | c <= 0xFFFF -> if c >= 0xD800 && c <= 0xDFFF then replacement else do put ptr (0xE0 .|. c shiftR 12) put (ptr plusPtr 1) (0x80 .|. c shiftR 6 .&. 0x3F) put (ptr plusPtr 2) (0x80 .|. c .&. 0x3F) return 3 c | c <= 0x10FFFF -> do put ptr (0xF0 .|. c shiftR 18) put (ptr plusPtr 1) (0x80 .|. c shiftR 12 .&. 0x3F) put (ptr plusPtr 2) (0x80 .|. c shiftR 6 .&. 0x3F) put (ptr plusPtr 3) (0x80 .|. c .&. 0x3F) return 4 _ -> replacement where put p c = poke p (fromIntegral c :: Word8) replacement = pokeUtf8 ptr '\xFFFD' withUtf8 :: String -> (CStringLen -> IO a) -> IO a withUtf8 string action = expand nullPtr 64 0 string where expand buf bufsize pos str = do buf' <- c_realloc buf (fromIntegral bufsize) when (buf' == nullPtr)$ do
c_free buf
ioError $userError "Out of memory" write buf' bufsize pos str write buf bufsize pos str | bufsize - pos < 4 = expand buf (bufsize * 2) pos str | otherwise = do case str of (c:cs) -> do len <- pokeUtf8 (buf plusPtr pos) c write buf bufsize (pos + len) cs [] -> do pokeByteOff buf pos (0 :: Word8) finish buf pos finish buf len = finally (action (buf, len)) (c_free buf) puts :: String -> IO () puts str = withUtf8 str (c_puts . fst) main :: IO () main = puts "\x266B Just another C hacker using Haskell \x266B"  JavaScript Run in console ({}+[])[!''+!''+!![]] + (!![]+[])[!''+!''] + (![]+[])[!''+!''+!''] + (!![]+[])[+![]] + ({}+[])[!![]+!''+!''+!''+!''+!''+!''] + (![]+[])[+!![]] + ([][{}]+[])[+!![]] + ({}+[])[+!''] + (!![]+[])[+![]] + 'h' + (![]+[])[!''+!''+!![]+!![]] + (!![]+[])[+!![]] + ({}+[])[!![]+!![]+!''+!''+!''+!''+!''] + ({}+[])[!![]+!''+!![]] + (![]+[])[!![]+!''+!![]] + ({}+[])[!![]+!![]+!![]+!![]+!''+!![]+!![]] + 'h' + (![]+[])[+!![]] + ({}+[])[!![]+!![]+!''+!![]+!![]] + 'k' + (![]+[])[!''+!![]+!![]+!''] + (!![]+[])[+!'']  Python 2.x (single expression) Now, while this is quite easy to figure out for Pythoneers, others might find it at least interesting. If you wonder why there's so many lambdas, I wanted to have maximum underscoreness, but minimal repetition. Who doesn't love underscores? Ideone (lambda ______________:(lambda ______,_______,________:(lambda _____:(lambda _,___,__,____,_____________:(lambda _________,__________:(lambda ___________,____________:___________(____________,____[_________**(_________+__________)-__________::_________+_________+_________]+_[__________::_________]+__[_________+__________])(____________,______________))((lambda _,__:________(______(_))[__]),(________(__import__(_[_________]+__[_________*_________+__________]+_[_________]))[_[_________:_________+_________]+___[__________/_________]+__[__________]+_____(u'')[__________/_________]+_[_________+__________]])))((_____________(_)+_____________(_))/_____________(_),_____________(_)/_____________(_)))(_____([]),_____({}),_____(None),_____({}.__iter__),lambda _:len(_)))(lambda _:_______(______(_))))((lambda _:_.__class__),(lambda _:_.__name__),(lambda _:_.__dict__)))('Just another Python Hacker\n')  An indented version if you prefer: (lambda ______________: (lambda ______,_______,________: (lambda _____: (lambda _,___,__,____,_____________: (lambda _________,__________: (lambda ___________,____________: ___________(____________,____[_________**(_________+__________)-__________::_________+_________+_________]+_[__________::_________]+__[_________+__________])(____________,______________)) ( (lambda _,__:________(______(_))[__]), (________(__import__(_[_________]+__[_________*_________+__________]+_[_________]))[_[_________:_________+_________]+___[__________/_________]+__[__________]+_____(u'')[__________/_________]+_[_________+__________]]))) ( (_____________(_)+_____________(_))/_____________(_), _____________(_)/_____________(_))) ( _____([]), _____({}), _____(None), _____({}.__iter__), lambda _:len(_))) ( lambda _:_______(______(_)))) ( (lambda _:_.__class__), (lambda _:_.__name__), (lambda _:_.__dict__)))('Just another Python Hacker\n')  This defines a function and calls it with 'Just another Python Hacker'. Now, it didn't have to be a function, but I thought it would be more elegant. f = (lambda ______________:(lambda ______,_______,________:(lambda _____:(lambda _,___,__,____,_____________:(lambda _________,__________:(lambda ___________,____________:___________(____________,____[_________**(_________+__________)-__________::_________+_________+_________]+_[__________::_________]+__[_________+__________])(____________,______________))((lambda _,__:________(______(_))[__]),(________(__import__(_[_________]+__[_________*_________+__________]+_[_________]))[_[_________:_________+_________]+___[__________/_________]+__[__________]+_____(u'')[__________/_________]+_[_________+__________]])))((_____________(_)+_____________(_))/_____________(_),_____________(_)/_____________(_)))(_____([]),_____({}),_____(None),_____({}.__iter__),lambda _:len(_)))(lambda _:_______(______(_))))((lambda _:_.__class__),(lambda _:_.__name__),(lambda _:_.__dict__))) f('Hello.\n') f('Just another Python Hacker here.\n')  • Oh, it's exactly 900 bytes. That is completely unintentional and awesome. – seequ Jun 10 '14 at 9:17 • And apparently it only works with Python 2.x – seequ Jun 10 '14 at 15:31 QBasic Here's my implementation in QBasic. The program must be called "JAQBH.BAS" in or for this to execute properly, as it reads its own source as part of the program. And I couldn't find any sane way of determining the name of the currently running script. COMMON SHARED JAQBH$
COMMON SHARED F$IF F$ = "" THEN F$= "A.BAS" OPEN F$ FOR OUTPUT AS #1
PRINT #1, JAQBH$DATA 20,16,28,24,16 DATA "Just Another QBasic Hacker" OPEN "JAQBH.BAS" FOR INPUT AS #2 FOR i% = 1 TO 5 READ l% y$ = INPUT$(l%, #2) PRINT #1, y$
y$= INPUT$(2, #2)
NEXT
CLOSE #1
CLOSE #2
F$= "CON" READ JAQBH$
CHAIN "A.BAS"

• is there any good way to compile or run qbasic under ubuntu? I tried a google search, installed freebasic and its giving me all kinds of errors. – Joel Berger Oct 2 '11 at 4:15
• this might work - repl.it (Uh, just tried it for this and it fails.) – DanBeale Oct 2 '11 at 6:35
• I don't imagine any online versions would allow writing of files – Kibbee Oct 2 '11 at 11:36
• Perhaps you could run it in DOSBOX – Kibbee Oct 2 '11 at 11:37
• I tested it in DOSBOX and it works perfectly. – mellamokb Oct 3 '11 at 16:46

import Control.Monad.State

newtype A a = A (Maybe a)
newtype B = B { c :: String }

instance Show a => Show (A a) where
show (A x) = show x

instance Show B where
show = c

s = [97, 13, 1, 5, -12, -3, 13, -82, 40, 25, 18,
-8, -6, 7, 0, -76, 72, -7, 2, 8, -6, 13]

main = print . A . fmap B . execWriterT . flip evalStateT 0 . mapM f $s where f x = modify (+x) >> get >>= tell . return . toEnum  Scala val bi = BigInt ("467385418330892203511763656169505613527047619265237915231602") bi.toByteArray.map (_.toChar).mkString  Postscript. Creates a custom font with which to display the text. %! 100 200[>>begin (Encoding{}FontType 3 BuildChar{exch begin 10 0 setcharwidth load exec stroke end} FontMatrix .1 0 0 .1 0 0 FontBBox 0 0 10 10) {token{exch}{exit}ifelse}loop {4 6}{array astore def}forall /c{1 string cvs 0 get}4{def}repeat /J c{7 9 moveto 7 2 lineto 6 4 1 360 190 arcn} /A c{2 2 moveto 5 8 lineto 8 2 lineto} /P c{3 2 moveto 3 8 lineto 3 6 2 90 270 arcn} /s c{5 7 2 0 270 arc 5 3 2 90 180 arcn} /H c{2 2 moveto 2 8 lineto 8 8 moveto 8 2 lineto 2 4 moveto 8 4 lineto}5{def}repeat /F currentdict end definefont 20 scalefont setfont moveto(JAPsH)show  Ruby Had two ideas and ended up combining them. def Object.const_missing(const) define_method(:method_missing) do |meth,*args| "#{meth}"['i'] ? ->a{not$*<<a.pop} :print(meth)
end[const,$\=' '] end Begin case %w[Just another ruby hacker] when tick puts 'tock' when tick puts 'tock' when tick puts 'tock' when tick puts 'tock' else eval($**\$\)
end


Ruby 1.9

Cheesy, highly implementation-dependent, but I hope you find it spooky.

class Object
define_method(:!) do |n=3|
send(methods.find{|la|la[/[slappy]{#{n}}/]})
end
end

(!!!:!).!(5) unless respond_to?('Just another ruby hacker,')


Edit: Proof

Python

My JAPH in Python

class Foo:
def __init__(s, t='Just another Python hacker'):
def g():
return [100,101,102,32,102,
40,120,41,58,112,114,
105,110,116,32,120],t
s.g = g()
class Z():
s.z = sum((chr(i)for i in s.g[0]),Z())
def __call__(s,t):
return t.join(map(chr,s))
def __iter__(s):
return (ord(i) for i in s)
def __repr__(s):
return s.g[-1]
def __getitem__(s, x):
exec s.z
f(s(x))
Foo()['']


JavaScript

eval (atob("ZnVuY3Rpb24gcHJpbnQoKSB7CmZ1bmN0aW9uIHRyKGEsYikgewogICAgcmV0dXJuIGEubWFwKGZ1bmN0aW9uKHgpewogICAgICAgIHJldHVybiB4LnRvU3RyaW5nKGIpOwogICAgfSkuam9pbignICcpOwp9CgoKdmFyIGEgPSJXemt5TmpNNE1Td3lNekl3TURJek1UYzNPU3d4TVRnMU5UTTNMREV3TkRVek1EYzBOelZkIjsKYSA9IGF0b2IoYSk7CmEgPSBKU09OLnBhcnNlKGEpOwphID0gdHIoYSwzNik7CmNvbnNvbGUubG9nKGEpOwp9"));
print();


Lua/RProgN

print "Just "           --                         Write Just to the Console--
print "Another "        --                      Write Another to the Console--
print "Lua "            --           Write Lua, definitely NOT  [ 'RProgN' ]--
print "Hacker "         -- Do u really thing u r an hacker like i [ ur NOT ]--


I'm sure there's a better and sneakier way to combine these two languages. Hiding in comments is just so overused.

Try the Lua Out

Try the RProgN Out

Operation Flashpoint scripting language

removeAllWeapons player
s = primaryWeapon player
call = "scripting " else "language "

a = [if true, if false]
b = ["s=s+(call select 0)", format["s=s+(call select 1)%1%2=%3", {;}, "call", {nil}]]

a select 0 then b
a select 1 then b

a = a + getPos player + [{Just another} + format ([" %1 %2 "] + ("Operation" ELSE "Flashpoint"))]

"b = format[""%2%1%3."", s, _x, call""""""hacker""""""]" count a

titleText (b else "plain")

exit


Save as ofp.sqs (or any other name), and call with [] exec "ofp.sqs".

Output:

Canvas

³｛┤：js nte avshce＠；utaohrcna akr＠｝）∑╷


...which should work, but ╷ on strings hasn't been implemented yet. Hooray for dead projects! The working version uses the same logic, but is a bit... less obfuscated.

Try it online! (working version)

Perl on OSX 10.7+ (requires Xcode)

#!/usr/bin/perl
use Inline C=>q{int g(){atexit("j\31\350\31\0\0\0Just \
another Perl hacker\n1\300@\220\17\204\n\0\0\0j\1k\4\x\
cd\x80\203\304\20\303^j\1_Z\270\4\0\0\2\17\5\303");}};g