JRSmile Posted May 26, 2013 Share Posted May 26, 2013 Hi Everyone, here again a POC (as always). Today a irc server which can take command from an irc client and execute functions and reply with answers. it is very basic so you can modify to your needs, enjoy. you will need the by the marvelous Kip for it to work. expandcollapse popup#include "TCP.au3" $hServer = _TCP_Server_Create(6667); A IRC server. Tadaa! Global $GLOBAL_hSocket, $connected, $motd = False, $username AdlibRegister("pingpong", 60000) AdlibRegister("sendmodt", 1000) _TCP_RegisterEvent($hServer, $TCP_NEWCLIENT, "NewClient") _TCP_RegisterEvent($hServer, $TCP_DISCONNECT, "Disconnect") _TCP_RegisterEvent($hServer, $TCP_RECEIVE, "Received") While 1 WEnd Func NewClient($hSocket, $iError) ConsoleWrite("New Client: " & $hSocket & @CRLF) $connected = True $motd = True $GLOBAL_hSocket = $hSocket EndFunc ;==>NewClient Func Disconnect($hSocket, $iError) ConsoleWrite("!Disconnect: " & $hSocket & @CRLF) $connected = False $GLOBAL_hSocket = False EndFunc ;==>Disconnect Func Received($hSocket, $sReceived, $iError) Local $msg = StringSplit($sReceived, @LF) For $i = 0 To UBound($msg) - 1 Step 1 rcv_msg($hSocket, $msg[$i], $iError) Next EndFunc ;==>Received Func rcv_msg($hSocket, $msg, $iError) ConsoleWrite("+receive:" & $msg & @CRLF) If StringLeft($msg, 4) = "ping" Then ircsend($hSocket, StringReplace($msg, "ping", "pong") & @CRLF) If StringLeft($msg, 4) = "NICK" Then $username = StringTrimLeft($msg, 5) If StringLeft($msg, 17) = "PRIVMSG #autoit :" Then ircsend($hSocket, ":root!root PRIVMSG #autoit :" & StringTrimLeft($msg, 17) & @CRLF) commands(StringTrimLeft($msg, 17)) EndIf EndFunc ;==>rcv_msg Func pingpong() If $connected Then ircsend($GLOBAL_hSocket, "PING :" & Random(1000, 9999, 1) & @CRLF) EndFunc ;==>pingpong Func sendmodt() If $motd Then For $i = 1 To 1 ircsend($GLOBAL_hSocket, ":localhost 001 " & $username & " :Welcome to the AutoIT Internet Relay Chat Network " & $username & "" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 002 " & $username & " :Your host is localhost[localhost/6667], running version AutoIT-Console v0.1" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 375 " & $username & " :- localhost Message of the Day -" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 372 " & $username & " :- Welcome to AutoIT - The Open and Free Management System" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 376 " & $username & " :End of /MOTD command." & @CRLF) ircsend($GLOBAL_hSocket, ":" & $username & "!" & $username & " JOIN :#autoit" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 332 " & $username & " #autoit :Welcome to the AutoIT Console v0.1" & @CRLF) ircsend($GLOBAL_hSocket, ":localhost 353 " & $username & " @ #autoit :root " & $username & "" & @CRLF) ircsend($GLOBAL_hSocket, "366 " & $username & " #bitlbee :End of /NAMES list." & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :Hi" & $username & @CRLF) Next EndIf $motd = False EndFunc ;==>sendmodt Func ircsend($GLOBAL_hSocket, $msg) ConsoleWrite("-output :" & $msg) TCPSend($GLOBAL_hSocket, $msg) EndFunc ;==>ircsend Func commands($command) Switch $command Case "status" ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :|----------------------------STATUS----------------------------|" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("Computername: " & @ComputerName) & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("IPAdress1: " & @IPAddress1) & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("Username: " & @UserName) & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) Case "help" ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :|-----------------------------HELP-----------------------------|" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("List of commands that can be issued against root") & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("help you are looking at it") & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :" & padmsg("status shows the current status of the server") & @CRLF) ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :+--------------------------------------------------------------+" & @CRLF) Case Else ircsend($GLOBAL_hSocket, ":root!root PRIVMSG #autoit :command unknown, try help" & @CRLF) EndSwitch EndFunc ;==>commands Func padmsg($msg) Local $len = StringLen($msg) Local $res = "| " $res &= $msg For $i = $len To 60 $res &= " " Next $res &= "|" Return $res EndFunc ;==>padmsg Best Regards, JR. $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now