Archive for the ‘programming’ Category

seni pengeliruan atucara

April 6th, 2008 8:49 pm

suatu ketika dahulu gua telah diperkenalkan dengan bahasa programming yang agak lucah tapi best iaitu “brainfuck”, setelah gua berjaya memahirkan diri maka gua jumpa plak beberapabenda baru dalam dunia berokgraming programming ni iaitu teknik pengeliruan aturaca. apa yang membuatkannya menarik adalah kerana teknik pengeliruan atucara ni banyak menggunakan rekursif (gua paling suka benda alah ni). oh ya.. mat saleh panggil benda ni “art of obfuscated programming

apa gunanya benda ni?? ada banyak sebenarnya tapi salah satu daripadanya adalah untuk menjaga program kita daripada di-reverse-engineering (BM: kejuruteraan terbalik?). orang buat virus biasanya guna teknik ni, tapi bila dah serabut serabut macam tu,mestilah ada banyak kelemahan macam susah nak maintain. apa apa pun, itu semua gua tak pedulik sangat sebenarnya, bagi gua obfuscating adalah satu seni pengaturcaraan. satu benda yang menarik dan penuh dengan misteri serta boleh kasi pecah otak.

oleh kerana gua bosan dan tiba tiba rasa gian nak coding, maka terhasilah karya pengeliruan atucara gua yang kedua

gua pening kapla

gua kira yang ni lebih elok la berbanding dengan cubaan keji gua yang pertama suatu ketika dahulu menggunakan konsep brainfuck dalam c programming

nanti next entry gua cuba explain macamana gua buat. (senang je ni sebab basic kepada basic untuk basic punya basic) — nak ganas-ganas takleh lagi, newbie la katakan hehe

sekian

why use nested if-else statement if you can write it in one line?

March 14th, 2008 11:41 am

when i’m showing my assignment code,

maxout = (strcmp(JenisAkaun,"TETAP") == 0) ? 500 : (strcmp(JenisAkaun,"BIASA") == 0) ? 10 : 0;

they look shocked like they never do programming before.. more surprising, even most of my friends from fsksm didn’t know this kind of coding exist.. lol!!! if you also one of them, then you better read back your programming book about conditional operator. so why we should know this thing?

have you ever encounter any programming condition that requires nested if-else statement like this

if ( $sa == a ) {if ( $kit ) {
do_somthing( $kit );
elsif ( $oo ) {
do_something_else( $oo );
}
else {
do_nothing();
}
}
elsif ( $tak == b ) {
if ( $laa ) {
other_func();
}
}
else {
go_die();
}

complex and look ugly isn’t? well you can write it in one line


(more…)

program a simple irc bot with ruby

May 30th, 2007 1:14 am

i spend my time learning socket programming in many languages such as c, c++, perl, ruby and etc.. but i like ruby most since it’s easier to handle especially when i can use regular expression to manipulate strings sent by server. after reading through ruby’s tutorial and understand a little bit of its concept i manage to code this simple ruby irc bot that can connect to irc and join a channel automatically. i also include some command to control the bot like ~join ~part ~say ~msg and ~quit to terminate the bot. it even have auto-jawab salam function..hehe

here’s the code

print "ruby irc bot\\nbrought to you by novatechnhttp://wan.pengganas.net\\n"

require 'socket'
server = "java.webchat.org"
port = "6667"

bot = TCPSocket.open(server,port)
bot.send("USER novaBot novaBot novaBot :Written in Ruby ;) \\r\\n", 0)
bot.send("NICK botcapayam\\r\\nJOIN #database\\r\\n", 0)    

stay = 1
while stay == 1
    str = String.new(bot.readline) #i don't know why i did this
    #check if we have ping
    if /^PING :(.*)/.match(str)
        bot.send("PONG #$1\\r\\n", 0)
    end

    if /^:novatech!(.*)@(.*) PRIVMSG #(.*) :(.*)/.match(str)
        command = "#$3 #$4"
        bot.send("PRIVMSG ##$1 #$2\\r\\n", 0) if command =~ /(.*) ~say (.*)/
        bot.send("PRIVMSG #$2\\r\\n", 0) if command =~ /(.*) ~msg (.*)/
        bot.send("JOIN ##$2\\r\\n", 0) if command =~ /(.*) ~join (.*)/
        bot.send("PART ##$2\\r\\n", 0) if command =~ /(.*) ~part (.*)/
    	stay = 0 if command =~ /(.*) ~quit/
    end
    if /^:(.*)!(.*)@(.*) PRIVMSG #(.*) :(askum|assalamualaikum|akum|a'kum)/.match(str)
        bot.send("PRIVMSG ##$4 wa'alaikumussalam #$1\\r\\n", 0)
    end
#puts bot.readline // for debug purpose
end #end while
bot.close

yea~ i’m suck in regular expressing..lol~!!

download the source code if you can’t copy code above properly

if you want to expend its features, then all you need to do is learn yourself how to manage strings in ruby…and of course a lot of regex practice -_- hehe… see ya

to all banjirian peoples.. apa kata korang semua cuba try ekjas buat rimut tibai ruby plak? apa macam ada brani? aku dah cek… laju daripada rimut irc, tapi apakan daya aku dah pencen — mesej tajaan srilanka

note : please change my nick novatech to your own nick

absolute brain damage

March 22nd, 2007 7:03 pm

++++++++++[>+++++++++++>+++++++++>++++++++++++< <<-]>+++++.>+++++++.>+.
< .>>++++++++++++++++++++++++++++++++.< <<+.>.< - - - - - - - - - .- - - - - - -.+.>>>.< <<++++.- - - - -.+.>.>>.< <<+++++++++.>.< - - -.>>>.< - - - - - - - - - .-.++++.+.>.< <.>
- - - - .< .<<++++++++++[>>>>>++++< <<<<-]>>>>>++++++.< .<+++.<.>++++++.< .>>.
< - - - - - - .<<- - - - - - .++++++.>.>-.< .<+++.- - - - - - -.>>>.< ++.<<.+.>>>.< <<+++++.
>++++.< +.>++..++.+++.- - - - - - - - - - -.< - - -.>.< +++.>>>.< <+++.<- - - - -.>>- - .< <.
>>>.< <- - .<- - - - .>>- - - - - - .< -.>- - .< .>++++++++.>.< <+.-.<+++.>.>+.< .>>.< <+.
>-.< -.<+.>>- - - - .< <- - -.>>+++++++.< ++.<+++++.>>>>.[-]< [-]<- - - - - - - - - - - - <+
++++>>++++++++[-< <.>.>]

since the exam is over and i got plenty of time to waste, so i used it to learn craziest programming language ever called brainfuck. well, there are a lot of this kind of programming language such as whitespace and f*ckf*ck lang. just wait for right time to learn all of them :)

for this code, it took me about one and half hours to complete it. well i’m just a newbie. still cramping on doing complex loop operation and still having problem with substraction. -_-

btw, this brainfuck give me an idea to write an obfuscated C. so i’m writing it one in brainfuck then interpret it into C before start scramble it. yea i know it’s not obfuscate enough, but hey i’m not joining any competition. just do it for the sake of “learn” and having fun with it. huhu!!

note : if you are girl/ustaz/good boy. please, don’t compile it. [tongue5][stounge]

till then, see ya. i want to rest my brain. tomorrow got speech on how intel dual core being built from intel.

hackthissite.org basic web 6 decryption mirc snippet

October 31st, 2006 1:44 am

for those who being playing hackthissite.org basic web challange and stuck at level 6, actually it’s just a simple encryption, you can find the algorithm by try encrypt a string

for example

single character ‘a‘ will return ‘a‘, but when you encrypt ‘ab‘ it will return ‘ac‘ and when you encrypt abcdefgh it will return acegikmo. it show that its converting according to the possition of the character..

still blur??
try encrypt this 12345 string, it will give you 13579, this give us idea how the character are arranged according to their possition.

123 will be 1+0 2+1 3+1+1 = 135
456
will be 4+0 5+1 6+1+1 = 468

and so on…

this also prove that it can be decrypt by reverse it back.
encrypt : 456 will be 4+0 5+1 6+1+1 = 468
decrypt : 468 will be 4-0 5-1 6-1-1 = 456
i don’t know how to explain it more,
you might understand it by look at this mirc snippet

(more…)


who's online