1
mirror of git://git.acid.vegas/muhstik.git synced 2024-12-26 16:16:42 +00:00

Initial commit

This commit is contained in:
Dionysus 2021-04-04 12:50:39 -04:00
commit 5d6877afe8
Signed by: acidvegas
GPG Key ID: EF4B922DB85DC9DE
53 changed files with 37892 additions and 0 deletions

42
README.md Normal file
View File

@ -0,0 +1,42 @@
# muhstik
> irc flooding solution
## Information
muhstik, an enterprise-class fully functional IRC flooding solution for your mission-critical trolling needs, was retroactively created around December 1993 to help perpetuate the incessant wars on #gayteen.
It uses a state-of-the-art event-based system to concurrently connect to proxies and servers.
In fact, testing of an early version of one of muhstik's parent scripts is the reason that freenode now checks for open SOCKS proxies.
## Authors
* Louis Bavoil mulder@gmx.fr
* roadr bigmac@home.sirklabs.hu
* Leon Kaiser literalka@gnaa.eu
## Credits
* abez for ghost-writing ASIAN.
* Blackman Heartiez for his collection of nicks.
* freenode for providing the perfect environment for testing muhstik.
* h for his contributions to my understanding of Internet Protocol version 6, Domain Name Systems, and tunneling.
* incog for blogging with Rufas about AYSYN, ASIAN, and STUPID.
* JacksonBrown for writing 'banbot.pl', which I used to gather thousands of IRC nicks for muhstik.wordlist.
* Jmax for his many, many ideas from ASIAN and for his multiple blog sessions with vxp and madvirii. Also for coding nickspam.pl.
* l0de for blogging with Rufas about AYSYN, ASIAN, and STUPID.
* madvirii for his multiple blog sessions with Jmax and vxp.
* mef for writing AYSYN.
* Osama Bin Laden for his contributions to my chronic insomnia/PTSD and for being THE GREATEST MAN ALIVE. You were a shining beacon of hope for freedom worldwide, rest in peace.
* rshxd for blogging with Rufas about AYSYN, ASIAN, and STUPID.
* Rufas for writing ASIAN and STUPID, as well as blogging to l0de about the aforementioned scripts.
* sam because he no doubt helped with this somewhere, he's everywhere FFS.
* sloth for blogging to l0de about IPv6 botnets, and his collection of nicks.
* sparc for blogging with Rufas about AYSYN, ASIAN, and STUPID.
* thyme for blogging with Rufas about AYSYN, ASIAN, and STUPID.
* vxp for his multiple blog sessions with Jmax and madvirii.
* w00t (aka X) for his collection of nicks.
* chrono for leaking this private muhstik loldongs.
* acidvegas for keeping the dream alive.
## Mirrors
- [acid.vegas](https://acid.vegas/muhstik) *(main)*
- [GitHub](https://github.com/acidvegas/muhstik)
- [GitLab](https://gitlab.com/acidvegas/muhstik)

316
muhstik/CIDR.txt Normal file
View File

@ -0,0 +1,316 @@
$Id: /rb/doc/CIDR.txt 2 2008-12-17T03:10:09.215481Z androsyn $
CIDR Information
----------------
Presently, we all use IPv4. The format of IPv4 is the following:
A.B.C.D
Where letters 'A' through 'D' are 8-bit values. In English, this
means each digit can have a value of 0 to 255. Example:
129.56.4.234
Digits are called octets. Oct meaning 8, hence 8-bit values. An
octet cannot be greater than 255, and cannot be less than 0 (eg. a
negative number).
CIDR stands for "classless inter domain routing", details covered
in RFC's 1518 and 1519. It was introduced mainly due to waste within
A and B classes space. The goal was to make it possible to use
smaller nets than it would seem from (above) IP classes, for instance
by dividing one B class into 256 "C like" classes. The other goal was
to allow aggregation of routing information, so that routers could use
one aggregated route (like 194.145.96.0/20) instead of
advertising 16 C classes.
Class A are all these addresses which first bit is "0",
bitmap: 0nnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh (n=net, h=host)
IP range is 0.0.0.0 - 127.255.255.255
Class B are all these addresses which first two bits are "10",
bitmap: 10nnnnnn.nnnnnnnn.hhhhhhhh.hhhhhhhh (n=net, h=host)
IP range is 128.0.0.0 - 191.255.255.255
Class C are all these addresses which first three bits are "110",
bitmap: 110nnnnn.nnnnnnnn.nnnnnnnn.hhhhhhhh (n=net, h=host)
IP range is 192.0.0.0 - 223.255.255.255
Class D are all these addresses which first four bits are "1110",
this is multicast class and net/host bitmap doesn't apply here
IP range is 224.0.0.0 - 239.255.255.255
I bet they will never IRC, unless someone creates multicast IRC :)
Class E are all these addresses which first five bits are "11110",
this class is reserved for future use
IP range is 240.0.0.0 - 247.255.255.255
So, here is how CIDR notation comes into play.
For those of you who have real basic exposure to how networks are
set up, you should be aware of the term "netmask." Basically, this
is a IPv4 value which specifies the "size" of a network. You can
assume the word "size" means "range" if you want.
A chart describing the different classes in CIDR format and their
wildcard equivalents would probably help at this point:
CIDR version dot notation (netmask) Wildcard equivalent
-----------------------------------------------------------------
A.0.0.0/8 A.0.0.0/255.0.0.0 A.*.*.* or A.*
A.B.0.0/16 A.B.0.0/255.255.0.0 A.B.*.* or A.B.*
A.B.C.0/24 A.B.C.0/255.255.255.0 A.B.C.* or A.B.C.*
A.B.C.D/32 A.B.C.D/255.255.255.255 A.B.C.D
The question on any newbies mind at this point is "So what do all
of those values & numbers actually mean?"
Everything relating to computers is based on binary values (1s and
zeros). Binary plays a *tremendous* role in CIDR notation. Let's
break it down to the following table:
A B C D
-------- -------- -------- --------
/8 == 11111111 . 00000000 . 00000000 . 00000000 == 255.0.0.0
/16 == 11111111 . 11111111 . 00000000 . 00000000 == 255.255.0.0
/24 == 11111111 . 11111111 . 11111111 . 00000000 == 255.255.255.0
/32 == 11111111 . 11111111 . 11111111 . 11111111 == 255.255.255.255
The above is basically a binary table for the most common netblock
sizes. The "1"s you see above are the 8-bit values for each octet.
If you split an 8-bit value into each of it's bits, you find the
following:
00000000
^^^^^^^^_ 1sts place (1)
|||||||__ 2nds place (2)
||||||___ 3rds place (4)
|||||____ 4ths place (8)
||||_____ 5ths place (16)
|||______ 6ths place (32)
||_______ 7ths place (64)
|________ 8ths place (128)
Now, since computers consider zero a number, you pretty much have
to subtract one (so-to-speak; this is not really how its done, but
just assume it's -1 :-) ) from all the values possible. Some
examples of decimal values in binary:
15 == 00001111 (from left to right: 8+4+2+1)
16 == 00010000 (from left to right: 16)
53 == 00110101 (from left to right: 32+16+4+1)
79 == 01001111 (from left to right: 64+8+4+1)
254 == 11111110 (from left to right: 128+64+32+16+8+4+2)
So, with 8 bits, the range (as I said before) is zero to 255.
If none of this is making sense to you at this point, you should
back up and re-read all of the above. I realize it's a lot, but
it'll do you some good to re-read it until you understand :-).
So, let's modify the original table a bit by providing CIDR info
for /1 through /8:
A B C D
-------- -------- -------- --------
/1 == 10000000 . 00000000 . 00000000 . 00000000 == 128.0.0.0
/2 == 11000000 . 00000000 . 00000000 . 00000000 == 192.0.0.0
/3 == 11100000 . 00000000 . 00000000 . 00000000 == 224.0.0.0
/4 == 11110000 . 00000000 . 00000000 . 00000000 == 240.0.0.0
/5 == 11111000 . 00000000 . 00000000 . 00000000 == 248.0.0.0
/6 == 11111100 . 00000000 . 00000000 . 00000000 == 252.0.0.0
/7 == 11111110 . 00000000 . 00000000 . 00000000 == 254.0.0.0
/8 == 11111111 . 00000000 . 00000000 . 00000000 == 255.0.0.0
At this point, all of this should making a lot of sense, and you
should be able to see the precision that you can get by using CIDR
at this point. If not, well, I guess the best way to put it would
be that wildcards always assume /8, /16, or /24 (yes hello Piotr,
we can argue this later: I am referring to IPs *ONLY*, not domains
or FQDNs :-) ).
This table will provide a reference to all of the IPv4 CIDR values
cidr|netmask (dot notation)
----+---------------------
/1 | 128.0.0.0
/2 | 192.0.0.0
/3 | 224.0.0.0
/4 | 240.0.0.0
/5 | 248.0.0.0
/6 | 252.0.0.0
/7 | 254.0.0.0
/8 | 255.0.0.0
/9 | 255.128.0.0
/10 | 255.192.0.0
/11 | 255.224.0.0
/12 | 255.240.0.0
/13 | 255.248.0.0
/14 | 255.252.0.0
/15 | 255.254.0.0
/16 | 255.255.0.0
/17 | 255.255.128.0
/18 | 255.255.192.0
/19 | 255.255.224.0
/20 | 255.255.240.0
/21 | 255.255.248.0
/22 | 255.255.252.0
/23 | 255.255.254.0
/24 | 255.255.255.0
/25 | 255.255.255.128
/26 | 255.255.255.192
/27 | 255.255.255.224
/28 | 255.255.255.240
/29 | 255.255.255.248
/30 | 255.255.255.252
/31 | 255.255.255.254
/32 | 255.255.255.255
So, let's take all of the information above, and apply it to a
present-day situation on IRC.
Let's say you have a set of flooding clients who all show up from
the following hosts. For lack-of a better example, I'll use a
subnet here at Best:
nick1 (xyz@shell9.ba.best.com) [206.184.139.140]
nick2 (abc@shell8.ba.best.com) [206.184.139.139]
nick3 (foo@shell12.ba.best.com) [206.184.139.143]
Most people will assume the they were all in the same class C
(206.184.139.0/24 or 206.184.139.*).
This, as a matter of fact, is not true. Now, the reason *I* know
this is solely because I work on the network here; those IPs are
not delegated to a class C, but two portions of a class C (128 IPs
each). That means the class C is actually split into these two
portions:
Netblock IP range
-------- --------
206.184.139.0/25 206.184.139.0 to 206.184.139.127
206.184.139.128/25 206.184.139.128 to 206.184.139.255
For the record, 206.184.139.0 and 206.184.139.128 are both known as
"network addresses" (not to be confused with "netblocks" or "Ethernet
hardware addresses" or "MAC addresses"). Network addresses are
*ALWAYS EVEN*.
206.184.139.127 and 206.184.139.255 are what are known as broadcast
addresses. Broadcast addresses are *ALWAYS ODD*.
Now, the aforementioned list of clients are in the 2nd subnet shown
above, not the first. The reason for this should be obvious.
The remaining question is, "Well that's nice, you know what the netblock
is for Best. What about us? We don't know that!"
Believe it or not, you can find out the network block size by using
whois -h WHOIS.ARIN.NET on the IP in question. ARIN keeps a list of
all network blocks and who owns them -- quite useful, trust me. I
think I use ARIN 5 or 6 times a day, especially when dealing with
D-lines. Example:
$ whois -h whois.arin.net 206.184.139.140
Best Internet Communications, Inc. (NETBLK-NBN-206-184-BEST)
345 East Middlefield Road
Mountain View, CA 94043
Netname: NBN-206-184-BEST
Netblock: 206.184.0.0 - 206.184.255.255
Maintainer: BEST
Does this mean you should D-line 206.184.0.0/16? Probably not.
That's an entire class B-sized block, while you're only trying
to deny access to a subnetted class C.
So then how do you get the *real* info? Well, truth is, you don't.
You have to pretty much take a guess at what it is, if ARIN reports
something that's overly vague. Best, for example, was assigned the
above class B-sized block. We can subnet it however we want without
reporting back to ARIN how we have it subnetted. We own the block,
and that's all that matters (to ARIN).
Not all subnets are like this, however. Smaller subnets you may
find partitioned and listed on ARIN; I've seen /29 blocks for DSL
customers show up in ARIN before.
So, use ARIN any chance you get. The more precision the better!
Now, there is a small issue I want to address regarding use of CIDR
notation. Let's say you D-line the following in CIDR format (hi
sion ;-) ):
205.100.132.18/24
Entries like this really makes my blood boil, solely because it adds
excessive confusion and is just basically pointless. If you
examine the above, you'll see the /24 is specifying an entire
class C -- so then what's the purpose of using .18 versus .0?
There IS no purpose. The netmask itself will mask out the .18 and
continue to successfully use 205.100.132.0/24.
Doing things this way just adds confusion, especially on non-octet-
aligned subnets (such as /8, /16, /24, or /32). Seeing that on a
/27 or a /19 might make people go "wtf?"
I know for a fact this doc lacks a lot of necessary information,
like how the actual netmask/CIDR value play a role in "masking out"
the correct size, and what to do is WHOIS.ARIN.NET returns no
netblock information but instead a few different company names with
NIC handles. I'm sure you can figure this stuff out on your own,
or just ask an administrator friend of yours who DOES know. A lot
of us admins are BOFH types, but if you ask us the right questions,
you'll benefit from the answer quite thoroughly.
Oh, I almost forgot. Most Linux systems use a different version of
"whois" than FreeBSD does. The syntax for whois on Linux is
"whois <INFO>@whois.arin.net", while under FreeBSD it is
"whois -h whois.arin.net <INFO>" Debian uses yet another version
of whois that is incompatible with the above syntax options.
Note that the FreeBSD whois client has shortcuts for the most commonly
used whois servers. "whois -a <INFO>" is the shortcut for ARIN.
Also note that ARIN is not authoritative for all IP blocks on the
Internet. Take for example 212.158.123.66. A whois query to ARIN
will return the following information:
$ whois -h whois.arin.net 212.158.123.66
European Regional Internet Registry/RIPE NCC (NET-RIPE-NCC-)
These addresses have been further assigned to European users.
Contact information can be found in the RIPE database, via the
WHOIS and TELNET servers at whois.ripe.net, and at
http://www.ripe.net/db/whois.html
Netname: RIPE-NCC-212
Netblock: 212.0.0.0 - 212.255.255.255
Maintainer: RIPE
This query tells us that it is a European IP block, and is further
handled by RIPE's whois server. We must then query whois.ripe.net
to get more information.
$ whois -h whois.ripe.net 212.158.123.66
% Rights restricted by copyright. See
http://www.ripe.net/ripencc/pub-services/db/copyright.html
inetnum: 212.158.120.0 - 212.158.123.255
netname: INSNET-P2P
descr: Point to Point Links for for London Nodes
country: GB
--snip--
This tells us the actual IP block that the query was a part of.
Other whois servers that you may see blocks referred to are:
whois.ripn.net for Russia, whois.apnic.net for Asia, Australia, and
the Pacific, and whois.6bone.net for IPv6 blocks.
Contributed by Jeremy Chadwick <jdc@best.net>
Piotr Kucharski <chopin@sgh.waw.pl>
W. Campbell <wcampbel@botbay.net> and
Ariel Biener <ariel@fireball.tau.ac.il>

117
muhstik/MONITOR.txt Normal file
View File

@ -0,0 +1,117 @@
MONITOR - Protocol for notification of when clients become online/offline
Lee Hardy <lee -at- leeh.co.uk>
$Id: monitor.txt 23973 2007-06-30 22:28:55Z jilles $
-------------------------------------------------------------------------
Currently, ISON requests by clients use a large amount of bandwidth. It is
expected that it is more efficient for this to be done by the server at the
expense of cpu cycles. The WATCH implementation that was designed to counter
this is (in my opinion) severely flawed. This protocol was designed to
provide a cleaner implementation.
The command used throughout this specification is "MONITOR".
Each use of the MONITOR command takes a special modifier, indicating
the operation being performed. The client MUST NOT attempt to specify
more than one modifier. Only one special modifier may be used per MONITOR
command.
Thus it is impossible to combine additions to the list with removals from
the list -- these MUST be done with two seperate commands.
A client MUST NOT issue the MONITOR command more than once per second.
Any attempts to do so will generate an error.
In commands and numerics where multiple nicknames may occur, the length of
the nickname list is limited only by the buffer size of 512 chars, as
defined in RFC1459.
Support of this specification is indicated by the MONITOR token in
RPL_ISUPPORT (005). This token takes an optional parameter, of the maximum
amount of nicknames a client may have in their monitor list. If no
parameter is specified, there is no limit. A typical token would be:
MONITOR=100
MONITOR + nick[,nick2]*
-----------------------
Adds the given list of nicknames to the list of nicknames being monitored.
If any of the nicknames being added are online, the server will generate
RPL_MONONLINE numerics listing those nicknames that are online.
If any of the nicknames being added are offline, the server will generate
RPL_MONOFFLINE numerics listing those nicknames that are offline.
MONITOR - nick[,nick2]*
-----------------------
Removes the given list of nicknames from the list of nicknames being
monitored. No output will be returned for use of this command.
MONITOR C
---------
Clears the list of nicknames being monitored. No output will be returned
for use of this command.
MONITOR L
---------
Outputs the current list of nicknames being monitored. All output will use
RPL_MONLIST, and the output will be terminated with RPL_ENDOFMONLIST
MONITOR S
---------
Outputs for each nickname in the list being monitored, whether the client is
online or offline. All nicks that are online will be sent using
RPL_MONONLINE, all nicks that are offline will be sent using RPL_MONOFFLINE.
The list will be terminated with RPL_ENDOFMONLIST.
Numeric replies
---------------
730 - RPL_MONONLINE
-------------------
:<server> 730 <nick> :nick!user@host[,nick!user@host]*
This numeric is used to indicate to a client that either a nickname has just
become online, or that a nickname they have added to their monitor list is
online.
The server may send "*" instead of the target nick (<nick>). (This makes it
possible to send the exact same message to all clients monitoring a certain
nick.)
731 - RPL_MONOFFLINE
--------------------
:<server> 731 <nick> :nick[,nick1]*
This numeric is used to indicate to a client that either a nickname has just
left the irc network, or that a nickname they have added to their monitor
list is offline.
The argument is a chained list of nicknames that are offline.
As with 730 the server may send "*" instead of the target nick.
732 - RPL_MONLIST
-----------------
:<server> 732 <nick> :nick[,nick1]*
This numeric is used to indicate to a client the list of nicknames they have
in their monitor list.
733 - RPL_ENDOFMONLIST
------------------------
:<server> 733 <nick> :End of MONITOR list
This numeric is used to indicate to a client the end of a monitor list.
734 - ERR_MONLISTFULL
---------------------
:<server> 734 <nick> <limit> <nicks> :Monitor list is full.
This numeric is used to indicate to a client that their monitor list is
full, so the command failed. The <limit> parameter is the maximum number of
nicknames a client may have in their list, the <nicks> parameter is the list
of nicknames, as the client sent them, that cannot be added.

10
muhstik/MOTD Normal file
View File

@ -0,0 +1,10 @@
_ _ _ _
_ __ ___ _ _| |__ ___| |_(_) | __
| '_ ` _ \| | | | '_ \/ __| __| | |/ /
| | | | | | |_| | | | \__ \ |_| | < 4.2.3
|_| |_| |_|\__,_|_| |_|___/\__|_|_|\_\
Maintainer: Leon Kaiser
E-mail: <literalka@gnaa.eu>
Web: <http://www.gnaa.eu/>
$ last rev: 59d302dcdfc42fada321c66a3afb66bf6d3cfe64 $

21
muhstik/Makefile Normal file
View File

@ -0,0 +1,21 @@
CC=gcc
CFLAGS=-Wsign-compare -Wall -I/usr/local/include
LDFLAGS=-L/usr/local/lib -lpthread
VPATH=src:build
OBJS=clone.o control.o init.o lists.o load.o mass.o muhstik.o net.o print.o proxy.o string.o
all: muhstik dork
muhstik: $(OBJS)
cd build; $(CC) $(LDFLAGS) -o ../muhstik $(OBJS)
.c.o:
$(CC) $(CFLAGS) -c -o build/$@ $<
notmp:
rm -f *~
rm -f */*~
clean: notmp
rm -f build/*.o
dork:
latex doc/TODO.tex
dvipdf TODO.dvi doc/TODO.pdf
rm -f TODO.dvi TODO.aux TODO.log texput.log

40
muhstik/NAMES Normal file
View File

@ -0,0 +1,40 @@
WORDS (TO YOUR MOTHER)
======================
* Cisco
* Demolish
* HTTP
* IRC
* Router
* Ruin
* SOCKS
* Syncronized
LIKE A (G) SIX
==============
* gaping
* galling
* glorious
* galvanizing
* gratuitous
* genital
* genocidal
* generous
ACRONYMS
========
ALLAH: A... L... L... A... H...
BINLADEN: B... IRC N... L... A... D... E... N...
CHIMPIN: C... Hyper-Intensive Multi Protocol IRC Nuker
CHINKS: Cisco HTTP IRC Nuker K... SOCKS
CHUFTER: Cisco HTTP U... F... T... E... Ruin
FAGGOT: F... A... G... G... O... T...
FATWAH: F... A... T... W... A... H...
GAYPORNO: G... A... Y... P... O... R... N... O...
JIHAD: J... IRC HTTP A... D...
MIRC: Masive IRC Ruining Clones
MUHSTIK: Massive Unwanted Homosexual Shitstorm Targeting IRC K...
NIGGERCUNT: Networked IRC Generating Glorious Enterprise Ruin Causing Unprecedented Night Terrors
OSAMA: O... Synchronized A... M... A...
RAPIST: Ruinous Assault Program IRC SOCKS Targeter
SANDNIGGER: Syncronized Assault Network Demolishing IRC Generating Gratuitous Eternal Ruin
SHITSKIN: SOCKS HTTP I... T... S... K... IRC Nuker

119
muhstik/SASL.txt Normal file
View File

@ -0,0 +1,119 @@
SASL authentication
-------------------
This document describes the client protocol for SASL authentication, as
implemented in charybdis and atheme.
SASL authentication relies on the CAP client capability framework [1].
Support for SASL authentication is indicated with the "sasl" capability.
The client MUST enable the sasl capability before using the AUTHENTICATE
command defined by this specification.
The AUTHENTICATE command
The AUTHENTICATE command MUST be used before registration is complete and
with the sasl capability enabled. To enforce the former, it is RECOMMENDED
to only send CAP END when the SASL exchange is completed or needs to be
aborted. Clients SHOULD be prepared for timeouts at all times during the SASL
authentication.
There are two forms of the AUTHENTICATE command: initial client message and
later messages.
The initial client message specifies the SASL mechanism to be used. (When this
is received, the IRCD will attempt to establish an association with a SASL
agent.) If this fails, a 904 numeric will be sent and the session state remains
unchanged; the client MAY try another mechanism. Otherwise, the server sends
a set of regular AUTHENTICATE messages with the initial server response.
initial-authenticate = "AUTHENTICATE" SP mechanism CRLF
A set of regular AUTHENTICATE messages transmits a response from client to
server or vice versa. The server MAY intersperse other IRC protocol messages
between the AUTHENTICATE messages of a set. The "+" form is used for an empty
response. The server MAY place a limit on the total length of a response.
regular-authenticate-set = *("AUTHENTICATE" SP 400BASE64 CRLF)
"AUTHENTICATE" SP (1*399BASE64 / "+") CRLF
The client can abort an authentication by sending an asterisk as the data.
The server will send a 904 numeric.
authenticate-abort = "AUTHENTICATE" SP "*" CRLF
If authentication fails, a 904 or 905 numeric will be sent and the
client MAY retry from the AUTHENTICATE <mechanism> command.
If authentication is successful, a 900 and 903 numeric will be sent.
If the client attempts to issue the AUTHENTICATE command after already
authenticating successfully, the server MUST reject it with a 907 numeric.
If the client completes registration (with CAP END, NICK, USER and any other
necessary messages) while the SASL authentication is still in progress, the
server SHOULD abort it and send a 906 numeric, then register the client
without authentication.
This document does not specify use of the AUTHENTICATE command in
registered (person) state.
Example protocol exchange
C: indicates lines sent by the client, S: indicates lines sent by the server.
The client is using the PLAIN SASL mechanism with authentication identity
jilles, authorization identity jilles and password sesame.
C: CAP REQ :sasl
C: NICK jilles
C: USER jilles cheetah.stack.nl 1 :Jilles Tjoelker
S: NOTICE AUTH :*** Processing connection to jaguar.test
S: NOTICE AUTH :*** Looking up your hostname...
S: NOTICE AUTH :*** Checking Ident
S: NOTICE AUTH :*** No Ident response
S: NOTICE AUTH :*** Found your hostname
S: :jaguar.test CAP jilles ACK :sasl
C: AUTHENTICATE PLAIN
S: AUTHENTICATE +
C: AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=
S: :jaguar.test 900 jilles jilles!jilles@localhost.stack.nl jilles :You are now logged in as jilles.
S: :jaguar.test 903 jilles :SASL authentication successful
C: CAP END
S: :jaguar.test 001 jilles :Welcome to the jillestest Internet Relay Chat Network jilles
<usual welcome messages>
Note that the CAP command sent by a server includes the user's nick or *,
differently from what [1] specifies.
Alternatively the client could request the list of capabilities and enable
an additional capability.
C: CAP LS
C: NICK jilles
C: USER jilles cheetah.stack.nl 1 :Jilles Tjoelker
S: NOTICE AUTH :*** Processing connection to jaguar.test
S: NOTICE AUTH :*** Looking up your hostname...
S: NOTICE AUTH :*** Checking Ident
S: NOTICE AUTH :*** No Ident response
S: NOTICE AUTH :*** Found your hostname
S: :jaguar.test CAP * LS :multi-prefix sasl
C: CAP REQ :multi-prefix sasl
S: :jaguar.test CAP jilles ACK :multi-prefix sasl
C: AUTHENTICATE PLAIN
S: AUTHENTICATE +
C: AUTHENTICATE amlsbGVzAGppbGxlcwBzZXNhbWU=
S: :jaguar.test 900 jilles jilles!jilles@localhost.stack.nl jilles :You are now logged in as jilles.
S: :jaguar.test 903 jilles :SASL authentication successful
C: CAP END
S: :jaguar.test 001 jilles :Welcome to the jillestest Internet Relay Chat Network jilles
<usual welcome messages>
[1] K. Mitchell, P. Lorier (Undernet IRC Network), L. Hardy (ircd-ratbox), P.
Kucharski (IRCnet), IRC Client Capabilities Extension. March 2005.
This internet-draft has expired; it can still be found on
http://www.leeh.co.uk/draft-mitchell-irc-capabilities-02.html
See also http://sasl.charybdis.be/ and
http://wiki.atheme.net/index.php/PR:SASL_Authentication (these links are
currently dead but may be resurrected in the future).
$Id: sasl.txt 3169 2007-01-28 22:13:18Z jilles $

BIN
muhstik/TODO.odt Normal file

Binary file not shown.

BIN
muhstik/TODO.pdf Normal file

Binary file not shown.

219
muhstik/TODO.tex Normal file
View File

@ -0,0 +1,219 @@
\documentclass{article}
\title{TODO}
\author{Leon Kaiser}
\date{2011-05-31}
\pagenumbering{arabic}
\pagestyle{headings}
\nofiles
\begin{document}
\maketitle
\tableofcontents
\contentsline {section}{\numberline {1}Tasks Organized by Priority}{2}
\contentsline {subsection}{\numberline {1.1}High Priority}{2}
\contentsline {subsection}{\numberline {1.2}Medium Priority}{2}
\contentsline {subsection}{\numberline {1.3}Low Priority}{3}
\contentsline {subsection}{\numberline {1.4}Unknown Priority}{3}
\contentsline {section}{\numberline {2}Relevant IRC/IRL logs:}{4}
\contentsline {subsection}{\numberline {2.1}Jmax}{4}
\contentsline {subsubsection}{\numberline {2.1.1}Jmax and madvirii}{4}
\contentsline {subsubsection}{\numberline {2.1.2}Jmax, vx`, and madvirii.}{4}
\contentsline {subsection}{\numberline {2.2}LiteralKa blogging to no-one in particular.}{5}
\contentsline {subsection}{\numberline {2.3}Rufas}{5}
\contentsline {subsubsection}{\numberline {2.3.1}Rufas, sparc, and thyme}{5}
\contentsline {subsubsection}{\numberline {2.3.2}Rufas, incog, and rshxd.}{6}
\contentsline {subsection}{\numberline {2.4}The l0de Radio Hour}{6}
\contentsline {subsubsection}{\numberline {2.4.1}Rufas at [S1E12] 16:26}{6}
\contentsline {subsubsection}{\numberline {2.4.2}Rufas at [20100409] 30:00}{6}
\contentsline {subsubsection}{\numberline {2.4.3}sloth at [20100409] 3:07:21}{7}
\newpage
% {{{ Tasks organized by priority
\section{Tasks Organized by Priority}\label{Tasks Organized by Priority}\index{Tasks Organized by Priority}
% {{{ High Priority
\subsection{High Priority}\label{High Priority}\index{High Priority}
\begin{itemize}
\item Support clone connections via {\tt TOR}.
\begin{itemize}
\item {\tt TOR} might actually already be supported by {\tt PROXY}.
\end{itemize}
\item File flooding with \emph{optional} adjustments for nick-length and latency.
\begin{itemize}
\item The reason for the `optional' bit is because one won't necessarily need a nick-length adjustment if the file being flooded is not an {\tt ASCII} file (in fact, it will just look weird.)
\end{itemize}
\item Permit (bot)net to target multiple networks (be able to send separate commands to an individual network's bots.
\item Implement {\tt STUPID}-like {\tt SSH} tunneling. ({\tt SSH Tunnel Utilizing Python IRC Destroyer}.)
\item {\tt nickspam.pl}-style nick spamming (using {\tt /NAMES} output.)
\end{itemize}
% }}}
% {{{ Medium Priority
\subsection{Medium Priority}\label{Medium Priority}\index{Medium Priority}
\begin{itemize}
\item Add `nickshuffle' with `nickbase' option.
\item {\tt do\_jupe()}:
\begin{itemize}
\item Call on \{de,re,\}connection.
\end{itemize}
\item muhstik's mechanism to do {\tt MODE}s and {\tt KICK}s sucks. It doesn't track any list of nicks to op, or nicks to {\tt KICK}, but it tries to change with simple {\tt MODE +o} and {\tt KICK}. This needs to be recoded with penalty handling.
\item Mass\{{\tt KNOCK},{\tt INVITE},{\tt TOPIC}\}.
\begin{itemize}
\item For mass{\tt INVITE}s, allow a mask (*!*@*.* style) `blacklist' of sorts, so that the clones don't {\tt INVITE} honeypot bots, lorf.
\end{itemize}
\item Add a `stop connect' command (`pause' or w/e.)
\begin{itemize}
\item It should toggle, obviously.
\end{itemize}
\item Max bots for connect -- maximum successful bots, not maximum connections.
\begin{itemize}
\item Allow increase/decrease.
\end{itemize}
\item Support {\tt SSL}/{\tt TLS} and {\tt SASL} {\tt IRC} connections%
\footnote[1]{Leach, P., Newman, C. \emph{Using Digest Authentication as a SASL Mechanism}, {\tt RFC 2831}, May 2000, (http://www.ietf.org/rfc/rfc2831.txt)}%
\footnote[2]{Myers, J. \emph{Simple Authentication and Security Layer (SASL)}, {\tt RFC 2222}, October 1997. (http://www.ietf.org/rfc/rfc2222.txt)}%
\footnote[3]{Newman, C. \emph{Anonymous SASL Mechanism}, {\tt RFC 2245}, November 1997. (http://www.ietf.org/rfc/rfc2245.txt)}
\item Fix the buffer overflow or what the fuck ever when scan mode is enabled.
\end{itemize}
% }}}
% {{{ Low Priority
\subsection{Low Priority}\label{Low Priority}\index{Low Priority}
\begin{itemize}
\item Inline documentation.
\item {\tt TOPIC} lock mode.
\item {\tt TOPIC} fight mode.
\item {\tt CTCP} responses.
\item Random colored messages.
\item Spam every person, (non-)\{op,ircop,voice\}, etc. in the channel.
\item \{Mass,Single\} reconnect (for evading {\tt ident} bans.)
\item Detect {\tt MODE +g} notifications on {\tt PRIVMSG}.
\begin{itemize}
\item Probably should just issue a warning or something.
\end{itemize}
\item Add \emph{optional} spectator -- bot that watches, and doesn't respond to `all'.
\item Modify bot behavior so that if a clone is the only `user' in a channel, the clone will cycle \emph{only} once. If deopped by ChanServ, etc. then give up.
\begin{itemize}
\item Possibly include a configuration setting that determines if channel registration is possible on the network ({\tt boolean}, on the off-chance that a network with NickServ doesn't have ChanServ, as it would otherwise be covered by {\tt conf.dalnet}.)
\end{itemize}
\item Does {\tt echo} mimic {\tt CTCP ACTION}s as well?
\item Allow \emph{optional} Cisco passwords (in format IP\{:PW,\}.)
\item {\tt do\_jupe()}:
\begin{itemize}
\item If ghosted, does the affected clone reconnect?
\end{itemize}
\end{itemize}
% }}}
% {{{ Unknown Priority
\subsection{Unknown Priority}\label{Unknown Priority}\index{Unknown Priority}
\begin{itemize}
\item {\tt do\_jupe()}:
\begin{itemize}
\item \_2\_ @ {\tt MONITOR}
\item Handle overflow.
\end{itemize}
\item {\tt .select *\&,}
\item {\tt .deaf}
\item Write or find some sort of tool that can differentiate between {\tt SOCKS4} and {\tt SOCKS5} proxies.
\item Should {\tt static} be used more?
\end{itemize}
% }}}
% }}}
% {{{ Relevant IRC/IRL logs:
\section{Relevant IRC/IRL logs:}\label{Relevant IRC/IRL logs:}\index{Relevant IRC/IRL logs:}
% {{{ Jmax
\subsection{Jmax}\label{Jmax}\index{Jmax}
% {{{ Jmax and madvirii.
\subsubsection{Jmax and madvirii}\label{Jmax and madvirii}\index{Jmax and madvirii}
02:32:57 $<$@Jmax$>$ maybe... add line numbers?\\
02:33:12 $<$+madvirii$>$ yah, like but it would have to be a system\\
02:33:19 $<$@Jmax$>$ or after the line is sent to chan, send a message to the next\\\indent bot\\
02:33:20 $<$+madvirii$>$ cuz it would get old editing your fav asciis\\
02:33:36 $<$@Jmax$>$ system?\\
02:33:44 $<$+madvirii$>$ yah like, read the txt file in line by line in an array, and\\\indent then assign a line number to each bot accordingly, if they got banned, it\\\indent might affect it, unless u design a failsafe, but it seems to be the right direction\\\indent to head in\\
02:34:50 $<$@Jmax$>$ if a bot can't send the message, it's delegated
% }}}
% {{{ Jmax, vx`, and madvirii.
\subsubsection{Jmax, vx`, and madvirii.}\label{Jmax, vx`, and madvirii.}\index{Jmax, vx`, and madvirii.}
02:44:38 $<$@Jmax$>$ if you mean \emph{cat}|(1)ting, then here's what I have in mind:\\
02:44:41 $<$@Jmax$>$ 1) determine latency\\
02:44:47 $<$ vx`$>$ if it's gonna have the ability to scroll an ascii with the whole\\\indent set of bots or some that ie. aren't banned on the channel\\
02:44:50 $<$@Jmax$>$ 2) ignore any bots with high latency, if there's enough bots\\
02:44:56 $<$ vx`$>$ then you wouldn't want some bots ruining the ascii because of\\\indent slow links\\
02:45:38 $<$+madvirii$>$ well, if we determine latency, and then just have the ten\\\indent fastest bots\\
02:45:52 $<$@Jmax$>$ no, we can't just ignore the bots\\
02:45:59 $<$ vx`$>$ hardly efficient\\
02:46:03 $<$@Jmax$>$ if we only have 10, then it'll still be limited. esp. if we have\\\indent 100 more\\
02:46:34 $<$ vx`$>$ apart from that, low latency links might get a) hit by the other\\\indent bots scrolling b) throttled c) \{banned,muted,shunned,glined\}\\
02:47:29 $<$@Jmax$>$ 3) determine which bots are capable of speaking in the\\\indent channel. (not\{muted,banned,shunned\}, etc.)\\
02:47:56 $<$ vx`$>$ freenode's ircd might have some gay features to suppress\\\indent ruining, and you don't necessarily get numerics from the ircd informing you\\
02:48:11 $<$+madvirii$>$ that is a good 3-step process to execute \emph{prior} to even\\\indent attempting to load a file\\
02:48:31 $<$@Jmax$>$ 4) pull the file into an array, and assign each line to one of\\\indent those bots\\
02:48:51 $<$@Jmax$>$ 5) measure nick length, pad accordingly\\
02:50:18 $<$ vx`$>$ but there are some time constraints on that code,\\\indent proportionally to the amount of bots you're scrolling with\\
02:50:28 $<$@Jmax$>$ actually, in step 4, do not assign each line to a bot, maintain\\\indent each list separately, a queue for \{bot,line\}s\\
02:55:02 $<$@Jmax$>$ 6) issue the first line to the first bot in queue, and make\\\indent the second bot wait for a successful message. If, during that time, it is\\\indent determined by the first bot that it \emph{cannot} send the message (and it's not a\\\indent latency issue), the line is re-assigned to the next bot in the queue and\\\indent removed from the queue.\\
02:55:34 $<$@Jmax$>$ 7) repeat until the file is complete.\\
02:55:52 $<$@Jmax$>$ that will ensure that, if a bot is kicked, the rest of the bots\\\indent take account for it\\
02:56:04 $<$+madvirii$>$ so the number of lines in the file queue will determine\\\indent the number of bot instances in the bot queue\\
02:56:05 $<$@Jmax$>$ and any lines assigned to that bot are not ignored\\
02:56:10 $<$@Jmax$>$ no, completely independent\\
02:56:27 $<$ vx`$>$ what do you in case of a line not arriving due to ie. unexpected\\\indent network problems, the link going down completely, etc.\\
02:56:39 $<$+madvirii$>$ ok so its just for lines in queue\\
02:57:24 $<$@Jmax$>$ well, that's what the second part of step 6 is for, but that\\\indent doesn't account for netsplits\\
02:57:48 $<$ vx`$>$ or any other network issues for that matter, like the proxy\\\indent going down or lagging, ...\\
03:00:02 $<$@Jmax$>$ sure it does, there will be a timeout, there will be the chance\\\indent that the bot is just very very lagged, and wasn't removed from the queue\\\indent earlier, and sends the message, reaches the timeout, and the other bot\\\indent replaces it, however, the message was still sent, so it will show up later\\
03:02:08 $<$ vx`$>$ sure, but out of order and if that'd happen too often it'd ruin\\\indent the whole thing\\
03:02:16 $<$@Jmax$>$ right: i think that will be a rarity
% }}}
% }}}
% {{{ LiteralKa blogging to no-one in particular.
\subsection{LiteralKa blogging to no-one in particular.}\label{LiteralKa blogging to no-one in particular.}\index{LiteralKa blogging to no-one in particular.}
13:51:56 $<$\&LiteralKa$>$ Maybe a command to spam a specific type of person in\\\indent a given channel: (non-)\{ops,ircops,voiced\}, all, etc.\\
13:53:34 $<$\&LiteralKa$>$ Synchronized ASCII flooding would be p. cool (read:\\\indent \emph{cat}(1)-style file flooding.)\\
13:53:48 $<$\&LiteralKa$>$ Like, delegate {\tt x} amount of lines to each bot based on\\\indent connection speed or some other algorithm or something.
% }}}
% {{{ Rufas
\subsection{Rufas}\label{Rufas}\index{Rufas}
% {{{ Rufas, sparc, and thyme
\subsubsection{Rufas, sparc, and thyme}\label{Rufas, sparc, and thyme}\index{Rufas, sparc, and thyme}
21:38:16 $<$+Rucas$>$ i highly suggest you check out {\tt STUPID}, run it from a very\\\indent fast box and it can DDOS an ircd just by flooding text in chat, {\tt SSH Tunnel\\\indent Utilizing Python IRC Destroyer}\\
21:38:54 $<$ sparc$>$ \emph{Rucas}: how fast of a box are we talking\\
21:39:00 $<$+Rucas$>$ 100mbit is perfect, basically you need enough bandwidth\\\indent to push all the OTHER boxes at a decent rate, it still does pretty well from\\\indent a standard cable line though\\
21:39:42 $<$ thyme$>$ cant do something like: start remote processes on machines\\\indent to avoid having to have one big monsterbox and just send signalling from\\\indent home box\\
21:40:09 $<$+Rucas$>$ well the original intent was cooperative flooding so like,\\\indent you'd have 5 hosts and they'd all paste lines of one ascii, so you could spam\\\indent asciis but bots wouldn't molish you but i never got around to that, because\\\indent of \emph{jenk}'s {\tt irc-rc}
% }}}
% {{{ Rufas, incog, and rshxd.
\subsubsection{Rufas, incog, and rshxd.}\label{Rufas, incog, and rshxd.}\index{Rufas, incog, and rshxd.}
21:42:43 $<$ rshxd$>$ \emph{Rucas}: since when did you write {\tt ASIAN}\\
21:42:50 $<$\&Rucas$>$ fucing years ago\\
21:42:59 $<$ rshxd$>$ I thought \emph{abez} wrote that for you\\
21:43:02 $<$\&Rucas$>$ no, i wrote it, and \emph{abez} rewrote part of it\\
21:43:04 $<$ incog$>$ before that was {\tt AYSYN}\\
21:43:13 $<$\&Rucas$>$ and then \emph{Jmax} rewrote that, and it is on {\tt ASIANv6} or some\\\indent shit, but i wrote {\tt ASIANv1}\\
21:43:36 $<$ incog$>$ was it based off \emph{mef}'s shit or all new?\\
21:43:42 $<$\&Rucas$>$ all new, i wish i had \emph{mef}'s code, but now i wrote {\tt STUPID}\\\indent which is much nicer than {\tt ASIAN}
% }}}
% }}}
% {{{ The l0de Radio Hour
\subsection{The l0de Radio Hour}\label{The l0de Radio Hour}\index{The l0de Radio Hour}
% {{{ Rufas at [S1E12] 16:26
\subsubsection{Rufas at [S1E12] 16:26}\label{Rufas at [S1E12] 16:26}\index{Rufas at [S1E12] 16:26}
\emph{l0de}: [If you steal that idea] my lawyers will fuck you so severely that it's not\\\indent even funny...\\
\emph{Rufas}: I'm sure they will, just like that guy's 800 bot botnet running wild on\\\indent EFNet right now.\\
\emph{l0de}: Holy shit, that's hillarious--he's got 800 bots now?\\
\emph{Rufas}: Yeah, he's up to 900 now.\\
\emph{l0de}: 900 fuckin' bots, through a JPEG redirect exploit-type of thing? [...] And\\\indent for our listeners, basically this guy coded an Internet Explorer link that runs\\\indent an mIRC exploit and basically \bf{turns your computar into botnet}\rm\\
\emph{Rufas}: And he authorized us to reverse engineer it [...] We can use it to assrape\\\indent \emph{\#politics}.
% }}}
% {{{ Rufas at [20100409] 30:00
\subsubsection{Rufas at [20100409] 30:00}\label{Rufas at [20100409] 30:00}\index{Rufas at [20100409] 30:00}
\emph{l0de}: Alright, so what people really want to hear about from you is the ruin:\\\indent the mega ruin that is going on. And you have this \bf{massive}\rm\symbol{32} fucking botnet\\\indent and you're annihilating everything that comes into contact with you. I know\\\indent Hardchats was DDoSed massively last night, primarily because of your\\\indent exploits. Why don't you tell us what happened?\\
\emph{Rufas}: Well, not a heck of a lot has really changed with what I've been doing.\\\indent I've used the new tool I wrote a few months ago called {\tt STUPID} but-\\
\emph{l0de}: Is this a reference to \emph{Max Goldberg}'s {\tt AYSYN}--no it was \emph{mef} that wrote\\\indent {\tt AYSYN} right?\\
\emph{Rufas}: \emph{mef} wrote {\tt AYSYN} and I wrote {\tt ASIAN} based on that which was {\tt Automated\\\indent Synchronous IRC Attack Network}. And then based on that I made {\tt STUPID},\\\indent which is {\tt SSH Tunnel Utilizing Python IRC Destroyer}--because they all\\\indent have to have some sort of stupid {\tt GNU} acronym to go with them.
% }}}
% {{{ sloth at [20100409] 3:07:21
\subsubsection{sloth at [20100409] 3:07:21}\label{sloth at [20100409] 3:07:21}\index{sloth at [20100409] 3:07:21}
\emph{sloth}: I've gotten a lot of comments about "Oh my God! This is the first IPv6\\\indent botnet I've ever seen."\\
\emph{sloth}: We are on the cutting edge of IRC flooding: we are pushing it into IPv6\\\indent and people just \bf{don't even know}\rm.
% }}}
% }}}
% }}}
% }}}
\end{document}

2641
muhstik/cisco.txt Normal file

File diff suppressed because it is too large Load Diff

13581
muhstik/ident.word Normal file

File diff suppressed because it is too large Load Diff

101
muhstik/include/clone.h Normal file
View File

@ -0,0 +1,101 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef CLONE_H
#define CLONE_H
#include "init.h"
#include "net.h"
#include "lists.h"
typedef struct
{
int type;
char mode;
char *save;
char *server;
unsigned short proxy_port;
unsigned short server_port;
} scan_t;
typedef struct
{
int id;
int type;
char *proxy;
unsigned short proxy_port;
char *server;
unsigned short server_port;
char *server_pass;
char *server_ident;
char *host;
unsigned short port;
int sock;
char *save;
char online;
char restricted;
int reco;
unsigned int monitor_tmax;
int grabbing;
char **jupes;
char op[MAX_CHANS];
char needop[MAX_CHANS];
char *nick;
char *nick2;
char *ident;
char *real;
queue queue;
char wait_whois;
scan_t *scan;
char mode;
char status;
time_t lastsend;
time_t start;
time_t alarm;
time_t rejoin_time;
char buffer[1024];
char lastbuffer[1024];
} clone_t;
typedef struct
{
char *parm;
void (*function) (clone_t *cl, char *cmd, char *nick, char *from, char *buf);
} msg_t;
void free_clone (clone_t *clone);
int main_clone (void *arg);
void save_host (clone_t *clone);
int not_a_clone (char *s);
int not_a_mast (char *s);
int is_enemy (char *s);
int is_op (clone_t *clone, int chid);
void op (clone_t *clone, int chid, char *s);
void deop (clone_t *clone, int chid, char *s);
int deop_enemy (clone_t *clone, int chid, char *nick);
void kick (clone_t *clone, int chid, char *s, char *reas, int mode);
void ban (clone_t *clone, int chid, char *s, int mode);
void unban (clone_t *clone, int chid, char *s);
void kickban (clone_t *clone, char *s);
void join (clone_t *clone, char *dest);
void echo (clone_t *clone, char *chan, char *buf);
void send_irc_nick (clone_t *clone, char *nick);
void register_clone (clone_t *clone);
void send2clones (char *buffer);
void send2server (clone_t *clone, const char *fmt, ...);
int parse_deco (clone_t *clone, char *buf);
void parse_irc (clone_t *clone, char *buf);
#endif

31
muhstik/include/control.h Normal file
View File

@ -0,0 +1,31 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef CONTROL_H
#define CONTROL_H
#include "clone.h"
typedef struct
{
char *parm;
void (*function) (char *buffer, int out);
} cmd_t;
int getchid (char *s);
clone_t *getop (int chid);
clone_t *getone (char *s);
clone_t *getscan ();
void interpret (char *buffer, int out);
#endif

74
muhstik/include/globals.h Normal file
View File

@ -0,0 +1,74 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#define VERSION "4.2.3"
/*
* The above `#define' _must_ be line number 4 for the `pre-commit' hook to
* work, and the MOTD file to stay intact.
*/
/* {{{ List lengths */
#define MAX_AOPS 128
#define MAX_PROTS 128
#define MAX_JUPES 128
#define MAX_SHITS 128
#define MAX_CHANS 64
#define MAX_NICKS 1024
#define MAX_IDENTS 1024
#define MAX_NAMES 1024
#define MAX_GROUPS 16
#define MAX_CLONES 1024
#define MAX_BROTHERS 1024
#define MAX_MUTEX 2
/* }}} */
/* {{{ Internal commands */
#define ADDOP "+aop"
#define RMOP "-aop"
#define ADDPROT "+prot"
#define RMPROT "-prot"
#define ADDJUPE "+jupe"
#define RMJUPE "-jupe"
#define ADDSHIT "+shit"
#define RMSHIT "-shit"
#define ADDSCAN "+scan"
#define RMSCAN "-scan"
#define KICKBAN "kb"
#define MASSKICK "mk"
#define MASSKICKBAN "mkb"
#define TAKEOVER "to"
#define MASSOP "mo"
#define MASSDEOP "md"
#define MASSUNBAN "mu"
#define NICKS "nicks"
#define NICKLIST "nicklist"
#define ECHO "echo"
#define CHANKEY "chankey"
#define STATUS "stat"
#define MUTE "mute"
#define PEACE "peace"
#define AGGRESS "agg"
#define RANDOM "random"
#define KILL "kill"
#define SELECT "select"
#define LOAD "load"
/* }}} */
/* {{{ Messages */
#define KICK_REAS "/!\\ this channel has moved to irc.gnaa.eu #gnaa /!\\"
#define SHIT_REAS "/!\\ this channel has moved to irc.gnaa.eu #gnaa /!\\"
#define SETON "activated"
#define CLOSE "+milk 1488 killjews"
/* }}} */
/* {{{ Buffer sizes */
#define MINIBUF 32
#define MINIBUF_TXT "32"
#define MEDBUF 128
#define MEDBUF_TXT "128"
#define BIGBUF 1024
#define BIGBUF_TXT "1024"
/* }}} */
/* To avoid mixing sleep() and usleep() */
#define sleep(t)\
usleep (t*1000000)
#endif

92
muhstik/include/init.h Normal file
View File

@ -0,0 +1,92 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef INIT_H
#define INIT_H
#include "globals.h"
#define USERLISTS 4
typedef enum {
AOP,
JUPE,
PROT,
SHIT
} list_t;
#define PROXYS 5
typedef enum {
SOCKS4,
SOCKS5,
PROXY,
CISCO,
VHOST,
NOSPOOF
} proxy_t;
typedef struct {
int load;
int group;
int max_clones;
int wait_socks;
int rewind_socks;
int timeout;
int max_reco;
int wait_reco;
int no_restricted;
int scan;
int help;
int verbose;
int debug;
int nocolor;
int dalnet;
int use_wordlist;
int nick_length;
int ident_length;
int real_length;
int rejoin;
int multi_op;
int multi_kick;
int multi_deop;
int aggressive;
int peace;
int repeat;
int notice;
/* int max_conns; */
char *motd;
char *batch;
char *g[PROXYS][MAX_GROUPS];
FILE *h[PROXYS][MAX_GROUPS];
FILE *s[PROXYS][MAX_GROUPS];
FILE *direct[2];
char *aop[MAX_AOPS];
char *jupe[MAX_JUPES];
char *juping[MAX_JUPES];
char *prot[MAX_PROTS];
char *shit[MAX_SHITS];
char *userlist[USERLISTS];
char *nicks[MAX_NICKS];
char *idents[MAX_IDENTS];
char *names[MAX_NAMES];
} config_t;
void init_options (char **argv);
void check_options();
void init_threads();
void init_hostname();
#endif

55
muhstik/include/lists.h Normal file
View File

@ -0,0 +1,55 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef LISTS_H
#define LISTS_H
#include "init.h"
/* Functions for handling files */
int occur_file (char *s, char *list);
void add_file (char *s, char *list);
int file_length (FILE *f);
int get_a_line (char *s, int z, FILE *f);
/* Functions for handling tables */
int add_table (char *toadd, char **list, int max);
int remove_table (char *torm, char **list, int max);
void update_table (char *from, char *to, char **list, int max);
void update_pattern_table (char *from, char *to, char **list, int max);
int occur_table (char *s, char **list, int max);
void fill_table (char **list, int max, FILE *f);
void clear_table (char **list, int max);
int match_table (char *s, char **list, int max);
/* Functions for handling single linked lists */
typedef struct st_list *queue;
struct st_list {
char *data;
queue next;
};
typedef int cmp_fun (char *s1, char *s2);
int add_queue (char *s, queue *list);
int uniq_add_queue (char *s, queue *list);
int remove_queue (char *d, queue *list);
void update_queue (char *old, char *new, queue *list);
int occur_queue (char *s, queue *list);
void free_cell (queue *list);
void clear_queue (queue *list);
void rotate_cell (queue *list);
#endif

29
muhstik/include/load.h Normal file
View File

@ -0,0 +1,29 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef LOAD_H
#define LOAD_H
#include "clone.h"
enum load_mode {
M_QUIT,
M_NOJOIN,
M_NORMAL
};
void *load_all (void *arg);
int load_host (int t, char *host, int proxy_port, char *server, int server_port, char *pass, char *ident, char *save, int mode);
void randget (clone_t *clone, char **dest, size_t destlen, int uselist, char **list, int max);
#endif

31
muhstik/include/mass.h Normal file
View File

@ -0,0 +1,31 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef MASS_H
#define MASS_H
#include "clone.h"
enum mass_actions {
MKB, /* Mass kickban */
MK, /* Mass kick */
MD, /* Mass deop */
TO /* Takeover */
};
void massdeop (clone_t *clone, int chid);
void massop (clone_t *clone, int chid);
void force_massop ();
void *init_massdo (int chid, int mode);
#endif

25
muhstik/include/muhstik.h Normal file
View File

@ -0,0 +1,25 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* Copyright (C) 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef MUHSTIK_H
#define MUHSTIK_H
#include "clone.h"
void read_batch ();
void read_stdin ();
int init_irc (clone_t *clone);
void main_exit ();
void main_loop ();
#endif

43
muhstik/include/net.h Normal file
View File

@ -0,0 +1,43 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef NETWORK_H
#define NETWORK_H
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <errno.h>
#define max(n1, n2)\
(n1 > n2 ? n1 : n2)
typedef struct
{
struct addrinfo *ip6_hostent;
} netstore;
void host2ip (char *s, char *host, int size);
int resolve (char *host, struct in_addr *addr);
netstore *net_store_new ();
void net_store_destroy (netstore *ns);
void net_set_socket_options (int sock);
void set_nonblocking (int sock);
int net_bind (netstore *ns, int sock);
int net_resolve (netstore *ns, char *hostname, unsigned short port);
int net_connect (netstore *ns, int *sock, char *vhost);
void send_sock (int sock, const char *fmt, ...);
#endif

32
muhstik/include/print.h Normal file
View File

@ -0,0 +1,32 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef PRINT_H
#define PRINT_H
#include "clone.h"
/* Functions for handling printing */
#define LEN_LINE 71
#define LEN_TAB 12
void print (int ret, int color, int dest, const char *fmt, ...);
void print_error(char *prefix);
void print_prefix (clone_t *clone, int color, int dest);
void print_line (int out);
void print_motd (int out);
void usage (int out);
void status (int out);
#endif

50
muhstik/include/proxy.h Normal file
View File

@ -0,0 +1,50 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef PROXY_H
#define PROXY_H
#include "clone.h"
enum states {
INIT,
WAIT_CONNECT,
WAIT_IDENT,
WAIT_IRC,
WAIT_SOCKS4,
WAIT_SOCKS5_1,
WAIT_SOCKS5_2,
WAIT_PROXY,
WAIT_CISCO,
WAIT_PASS,
WAIT_HOST,
WAIT_CMD,
EXIT
};
int connect_clone (clone_t *clone, char *host, unsigned short port);
int init_vhost (int sock, char *vhost);
int init_socks4 (clone_t *clone);
int init_socks5 (clone_t *clone);
int init_read_socks5 (clone_t *clone);
int init_proxy (clone_t *clone);
int init_bouncer (clone_t *clone);
int read_cisco (clone_t *clone);
int readline (int s, char *buffer, size_t buffer_size);
int read_proxy (clone_t *clone);
int read_socks4 (clone_t *clone);
int read_socks5 (clone_t *clone);
void sendnick (clone_t *clone, char *nick);
void senduser (clone_t *clone);
#endif

46
muhstik/include/string.h Normal file
View File

@ -0,0 +1,46 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
#ifndef STRING_H
#define STRING_H
#include <string.h>
#include <errno.h>
extern int errno;
/* Functions for handling strings */
/* A delimiter for strsep */
#define DELIM " \r\n"
void *xmalloc (size_t size);
char *StrDuplicate (char *src);
int StrCompare (char *s1, char *s2);
int StrCmpPrefix (char *s1, char *s2);
void StrFirstToken (char *s);
void StrCopy (char *s1, char *s2, size_t n);
void StrCat (char *s1, char *s2, size_t n);
int StrParam (char *parm, size_t size, char *s, int i);
int is_in (char *w, char *s);
#ifdef NO_STRSEP
char *strsep (char **stringp, const char *delim);
#endif
/* Functions for handling patterns */
int is_pattern (char *s);
int is_nick (char *s);
int match_pattern (char *pattern, char *s);
#endif

28
muhstik/ipv6/config.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/echo lol @ minorities
ipgen() {
if [ -n "$1" -a -n "$2" ]; then
printf '%x' $(shuf -i $1-$2 -n 1);
else
printf '%x' $(shuf -i 0-65535 -n 1);
# echo "error: ipgen() called with invalid params"
# exit 666
fi
}
DEV_NAME="he-ipv6"
SUBNET_TYPE="48"
if [ "$SUBNET_TYPE" -eq "48" ]; then
RAND_IP=`echo \`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen 1 65534\``
else # Assume /64
RAND_IP=`echo \`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen 1 65534\``
fi
##########################################
# Tunables #
##########################################
# Get these from "HE.net Tunnel Details" #
# (if using tunnelbroker.net) #
##########################################
EXT_IP6_TUN="2001:470:23:3f4::2" # "Client IPv6 address" #
EXT_IP6_PREFIX="2001:470:fcf4" # urmom #
EXT_IP6_LAN="${EXT_IP6_PREFIX}:${RAND_IP}" # An IP from the "Routed /{48,64}" range #
HE_TUN_SRV="74.82.46.6" # "Server IPv4 address" #
##########################################

178
muhstik/ipv6/h.sh Normal file
View File

@ -0,0 +1,178 @@
#!/bin/echo lol @ minorities
# $Id: h.sh 11 2011-05-29 literalka $
#
# {{{ Relevant WWW site links:
# [0] HOWTO
# [0a] http://mirrors.bieringer.de/Linux+IPv6-HOWTO/
# [1] Wiki
# [1a] http://en.wikipedia.org/wiki/IPv6
# [1b] http://en.wikipedia.org/wiki/IPv6_address
# [1c] http://en.wikipedia.org/wiki/Tunneling_protocol
# [1d] http://en.wikipedia.org/wiki/List_of_IPv6_tunnel_brokers
# [2] RFC
# [2a] http://tools.ietf.org/html/rfc2460
# [2b] http://tools.ietf.org/html/rfc3053
# [2c] http://tools.ietf.org/html/rfc3964
# [3] Tunnel Brokers
# [3a] http://www.tunnelbroker.net/
# [3b] http://tbroker.mybsd.org.my/
# [4] Amusing
# [4a] http://blogs.pcmag.com/securitywatch/2010/12/ipv6_will_worsen_the_spam_and.php
# [4b] http://jl.ly/Email/v6bl.html
# [5] DNS
# [5a] http://member.wide.ad.jp/~fujiwara/v6rev.html
# [5b] http://freedns.afraid.org/
# [5c] http://dns.he.net/
# [5d] http://freedns.afraid.org/reverse/instructions.php
# [6] VPS Hosts
# [6a] http://www.hostgator.com/
# }}}
# {{{ Notes:
# 1) Add ``EXT_IP6_TUN'' IP with /3 so it auto-adds a route to 2000::/3 to the
# tunnel device so that there is no need to explicitly add that route.
# 2) Add ``EXT_IP6_LAN'' IP with /3 so the route to the LAN prefix/64 is not
# auto-added to the tunnel device.
# 3) You could also add IPs with /128, but adding IPs with /3 auto-adds a route
# to 2000::/3 to the tunnel device, and with the ``EXT_IP6_TUN'' IP having
# that route auto-added already, the routing table is kept clean.
# 4) Last IP address added with "preferred_lft forever" is used as the default
# IP for new outgoing connections.
# 5) That being said, "preferred_lft x" is optional, defaulting to
# "preferred_lft forever".
# 6) Add additional IPs using:
# ip -6 addr add 2001:470:___:___::___/3 dev $DEV_NAME
# 7) Do not add any CIDRs, just add "straight up" IPs.
# }}}
# {{{ Suggestions:
# 1) If using tunnelbroker [3a], delegate the rDNS to ``dyn.ip6arpa.co.cc'', it
# /should/ give proper forward and reverse DNS, for "max sperg". Make sure
# it works first though, (i.e. freenode's DNS probably sucks).
# 2) <@h> ipv6 youtube + /48 = lol viewcounts
# 3) "...if you sent a billion messages a second, each with its own address,
# it would take about a thousand years to use all the addresses in a
# /64" [4b], thus, I would suggest sending one billion messages per second
# using different IP addresses.
# 4) Run your own rDNS (see [5a], requires root or sudo(8))
# 5) If you have 0.01 USD on Paypal and a valid US phone number, just get a
# Hostgator [6a] VPS with 4 ips on it using promo code "austin" (dunno how
# long this will be valid), you'd probably be able to run a DNS server on
# it, with 4 IPs.
# 6) If you use FreeDNS [5b], you can set up a ``vhost'' by delegating your rDNS
# to FreeDNS' servers and setting up an ``IPv6 Reverse'' [5d].
# 7) 19:07:20 <+h> I'm still trying to get ARIN to give me 14:88:/32
# 19:07:24 <+h> would be awesome as fuck
# 8) IPv6 botnets are relatively unknown, based on my own experience. I suggest
# fixing this with an "IPv6 Awareness" program of somesort.
# 9) Try to use as many "levels" (TODO: find the right word for this) of an IPv6
# IP as possible: when banning, many channel operators will ban a single
# IP, others will ban 2001:470:* (all of HE.net), and even some others
# will ban, say, a /64 when you're {ab,}using a /48, leaving unbanned IP
# addresses.
# }}}
# {{{ `telnet(1) route-server.he.net`
# [AS6939/HURRICANE-IPV6]
# ``tunnelbroker.net'' tunnel server information. Current as of 2011-03-29.
#
# Location IPv4 IPv6
#--------------------- ---------------- ------------------------
# North America
# PAIX Seattle 216.218.252.176 2001:470:0:3d::1
# PAIX Palo Alto 216.218.252.165 2001:470:0:1b::1
# Equinix San Jose 216.218.252.164 2001:470:0:1a::1
# Hurricane Fremont 1 216.218.252.161 2001:470:0:23::1
# Hurricane Fremont 2 216.218.252.162 2001:470:0:24::1
# Hurricane San Jose 216.218.252.163 2001:470:0:19::1
# Equinix Los Angeles 216.218.252.166 2001:470:0:1c::1
# One Wilshire Los Angeles 216.218.252.178 2001:470:0:6c::1
# Equinix Chicago 216.218.252.168 2001:470:0:16::1
# Equinix Dallas 216.218.252.167 2001:470:0:1d::1
# PAIX Toronto 216.218.252.147 2001:470:0:99::1
# Telehouse New York 216.218.252.170 2001:470:0:12::1
# PAIX New York 216.218.252.171 2001:470:0:13::1
# TelX New York 216.218.252.148 2001:470:0:9f::1
# Equinix Ashburn 216.218.252.169 2001:470:0:17::1
# TelX Atlanta 216.218.252.150 2001:470:0:a7::1
# NOTA Miami 216.218.252.177 2001:470:0:4a::1
# Telx Phoenix 216.218.252.156 2001:470:0:154::1
# Pittock Portland 216.218.252.159 2001:470:0:157::1
# Comfluent Denver 216.218.252.158 2001:470:0:155::1
# Level3 Kansas City 216.218.252.157 2001:470:0:156::1
# Oak Tower Kansas City 216.218.252.181 2001:470:0:178::1
# Minnesota Gateway 216.218.252.185 2001:470:0:ab::1
# Europe
# Telehouse London 216.218.252.172 2001:470:0:d::1
# NIKHEF Amsterdam 216.218.252.173 2001:470:0:e::1
# Interxion Frankfurt 216.218.252.174 2001:470:0:2a::1
# Interxion Paris 216.218.252.175 2001:470:0:2b::1
# Telehouse Paris 216.218.252.184 2001:470:0:1ae::1
# Equinix Zurich 216.218.252.153 2001:470:0:10c::1
# TeleCity Stockholm 216.218.252.154 2001:470:0:10f::1
# Asia
# Mega-I Hong Kong 216.218.252.180 2001:470:0:c2::1
# Equinix Tokyo 216.218.252.151 2001:470:0:10a::1
# Equinix Singapore 216.218.252.179 2001:470:0:169::1
# }}}
# {{{ Prerequisites and supported platforms:
# Tested on: bash(1) 4.0.33(1)-release on Ubuntu 2.6.31-23.74-generic
# Requires: bash(1), test(1), printf(1), echo(1), and ip(8)
# May Need: su(1), sudo(8), modprobe(8)
# }}}
# {{{ rcslog
# $Log: h.sh $
# Revision 11 2011/05/29 21:44:23 literalka
# Move config into its own file
#
# Revision 10 2011/04/27 01:10:19 literalka
# Added some small fucking retarded change in some obscure comment somewhere
# Added two more small fucking useless changes in an even more obscure comment
# And then I added a small stupid fucking change to one of those comments
#
# Revision 9 2011/04/21 22:52:04 literalka
# Small documentation updates
#
# Revision 8 2011/03/29 13:02:45 literalka
# Updated `telnet(1) route-server.he.net`
# Updated "Tested on"
#
# Revision 7 2011/02/10 12:21:45 literalka
# Add adjustable params to ipgen()
# Check for ``SUBNET_TYPE''
#
# Revision 6 2011/02/09 22:13:12 literalka
# Wrote ipgen(), replacing use of ``RANDOM''
#
# Revision 5 2011/02/09 20:08:12 literalka
# `telnet(1) route-server.he.net`
#
# Revision 4 2011/02/09 15:32:18 literalka
# Require bash(1)
#
# Revision 3 2011/02/04 12:56:24 literalka
# Replaced all instances of "he-ipv6" with ``DEV_NAME''
#
# Revision 2 2011/02/03 19:15:48 literalka
# rm useless "if" statement
#
# Revision 1 2011/01/22 18:05:48 literalka
# Initial revision
# }}}
# Last update: Wed Apr 27 2011
# -- by Leon Kaiser of the GNAA
# <literalka@gnaa.eu>
if [ -z "${BASH_VERSION}" ]; then
echo "error: use bash(1)" # require bash(1)
exit 1488
fi
#modprobe ipv6
source config.sh
ip tunnel add $DEV_NAME mode sit remote $HE_TUN_SRV ttl 255
ip link set $DEV_NAME up
ip -6 addr add $EXT_IP6_TUN/3 dev $DEV_NAME preferred_lft 0
ip -6 addr add $EXT_IP6_LAN/3 dev $DEV_NAME preferred_lft forever
echo "Added route to IP ${EXT_IP6_LAN}"
# tunnelbroker.net includes the following lines in their suggested
# "Linux-route2" config...
# ip route add ::/0 dev he-ipv6
# ip -f inet6 addr

10
muhstik/ipv6/he.sh Normal file
View File

@ -0,0 +1,10 @@
ipv4addr="AUTO"
_tunnelid=""
md5pass="" # echo -n ${PW} | md5sum
userid=""
tunnel_detail="http://ipv4.tunnelbroker.net/tunnel_detail.php?tid=${_tunnelid}" # &ajax={true,false}
nsupdate="http://ipv4.tunnelbroker.net/nsupdate.php?tid=${_tunnelid}"
ipv4_end="https://ipv4.tunnelbroker.net/ipv4_end.php?ip=${ipv4addr}&pass=${md5pass}&apikey=${userid}&tid=${_tunnelid}"
# -or-: https://USERNAME:PASSWORD@ipv4.tunnelbroker.net/ipv4_end.php?tid=TUNNELID (auto-detect IP)
# https://USERNAME:PASSWORD@ipv4.tunnelbroker.net/ipv4_end.php?tid=TUNNELID&ip=IPV4ADDR

13
muhstik/ipv6/vhosts.sh Normal file
View File

@ -0,0 +1,13 @@
source config.sh
rm "/home/literalka/git/muhstik/vhosts"
for (( i = 0; i < 100; i++ )); do
if [ "$SUBNET_TYPE" -eq "48" ]; then
RAND_IP=`echo \`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen 1 65534\``
else # Assume /64
RAND_IP=`echo \`ipgen\`:\`ipgen\`:\`ipgen\`:\`ipgen 1 65534\``
fi
ip -6 addr add ${EXT_IP6_PREFIX}:${RAND_IP}/3 dev ${DEV_NAME} preferred_lft 0
echo "${EXT_IP6_PREFIX}:${RAND_IP}" >> /home/literalka/git/muhstik/vhosts
done

47
muhstik/jupes.txt Normal file
View File

@ -0,0 +1,47 @@
g00n
Bratty
Brattiest
krashed
[krashed]
atomix
atomiku
itr
eGod
gotho
storm
chrono
chrono_
chrono-
_404
[0ne]
acid
KweeN
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
_
\
`

BIN
muhstik/muhstik Normal file

Binary file not shown.

154
muhstik/muhstik.conf Normal file
View File

@ -0,0 +1,154 @@
$Id: muhstik.conf 4.2.3 2011-05-31 literalka $
###################################################################
# CONNECTION SETTINGS #
###################################################################
# Uncomment the following lines if you wish to use SOCKS4.
#sock4_list socks4.txt
#sock4_server_list servers
#sock4_save good_4
# Uncomment the following lines if you wish to use SOCKS5.
#sock5_list socks5.txt
#sock5_server_list servers
#sock5_save good_5
# Uncomment the following lines if you wish to use PROXYS.
#proxy_list proxies.txt
#proxy_server_list servers
#proxy_save good_p
# Uncomment the following lines if you wish to use VHOSTS.
vhost_list vhosts
vhost_server_list servers6
#vhost_save good_vhosts
# Uncomment the following lines if you wish to use CISCO ROUTERS.
#cisco_list cisco.txt
#cisco_server_list servers
#cisco_save good_ciscos
# Uncomment the following line if you wish to use DIRECT CONNECTIONS.
# NOTE: This will _not_ hide your IP on connection.
#direct_server_list servers
###################################################################
# [OPTIONAL] LOADING SETTINGS #
###################################################################
# To specify milliseconds between loadings.
load 1000 # [default=2000]
# To specify a number of clones to load simultaneously.
group 20 # [default=1]
# To specify a number of clones with the same IP.
# Be careful with this: If you set it too high, you are most likely to get
# killed when you connect.
clones 2 # [default=1]
# Wait indefinitely for new proxys if associated servers are not full.
#wait 1 # [default=0]
# Rewind proxy lists when changing the server.
#rewind 1 # [default=0]
# Timeout (in seconds) to connect to the server.
#timeout 15 # [default=30]
# Limit the number of reconnections allowed by clone.
# NOTE: A negative number disables this quota.
max_reco 10 # [default=0]
# Time to wait (in seconds) before reconnecting a clone.
wait_reco 10 # [default=1]
# Don't use restricted connections.
#no_restricted 1 # [default=0]
# To terminate the clones as they connect successfully to IRC.
# Useful for checking proxy lists against blacklists.
# WARNING: Don't use it if you don't know what you are doing.
scan 0 # [default=0]
# If you want your bots to JOIN a channel on connection.
chan ##comment-on-staff
###################################################################
# [RECOMMENDED] DISPLAY SETTINGS #
###################################################################
# To specify the file that contains the MOTD.
# NOTE: This path must be relative to the current directory.
motd MOTD
# To see the available commands when starting a session.
#help 0 # [default=0]
# To see useful information, PRIVMSG, etc.
verbose 1 # [default=0]
# When little to no clones succeed to connect to IRC, use this.
debug 1 # [default=0]
# To disable colors in the console.
#nocolor 0 # [default=0]
###################################################################
# [RECOMMENDED] CONTROL SETTINGS #
###################################################################
# Execute commands from aops by NOTICE or PRIVMSG?
#notice 1 # [default=0]
# Load/save the auto op and protected user lists from/to files?
#aop_list frens # one pattern (nick!ident@host) per line
#jupe_list jupes # one nick per line
#prot_list prots # one nick per line
#shit_list shits # one line = nick!ident@host reason
# Run a batch of muhstik commands on startup
#onstart batch # one command per line
###################################################################
# [OPTIONAL] IRC SETTINGS #
###################################################################
# To consider the nick nickserv as the DALnet Service.
#dalnet 0 # [default=1]
# To pick the nicks, idents or realnames from a wordlist.
nicks muhstik.wordlist
idents ident.word
realnames muhstik.wordlist
# To use the wordlist on load
using_wordlist 1 # [default=0]
# To set the max length for the nicks or the realnames.
#nick_length 8 # [default=8] DALnet: up to 30; Regular: 8
#ident_length 8 # [default=8]
#real_length 10 # [default=8] Up to 30
# To specify the time (in seconds) between rejoins.
#rejoin 3 # [default=5]
# To set how many clones to op when one is opped.
multi_op 4 # [default=4]
# To set how many enemies to KICK per line in masskick.
# NOTE: Most servers don't understand multiple kicks at once.
#multi_kick 4 # [default=1]
# To set how many enemies to deop per line in massdeop.
multi_deop 4 # [default=4]
# To deop enemies actively and to kick them on PRIVMSG.
#aggressive 1 # [default=0]
# To disable deop
peace 1 # [default=0]
# To specify the number of times to repeat each line sent to IRC.
#repeat 2 # [default=0]

7209
muhstik/muhstik.wordlist Normal file

File diff suppressed because it is too large Load Diff

34
muhstik/prox/dns2ip.pl Normal file
View File

@ -0,0 +1,34 @@
#!/usr/bin/perl
use Net::DNS;
my $separator=:;
my $res=Net::DNS::Resolver->new;
while (<>){
chomp;
my ($host,$port) = split(/$separator/o,$_);
unless ($host=~m/^\d+\.\d+\.\d+\.\d+$/o) {
my $dnspack = $res->query($host,A);
if ($dnspack){
foreach my $rdata ($dnspack->answer){
my $rstr=$rdata->rdatastr;
print "$rstr$separator$port\n";
}
} else {
print "$host$separator$port\n";
}
} else {
print "$host$separator$port\n";
}
}
__END__
=head1 NAME
dns2ip - convert proxy list from HOST:PORT fromat to IP:PORT format
=head1 SYNOPSIS
dns2ip < host_port.txt > ip_port.txt

167
muhstik/prox/prox.tcl Normal file
View File

@ -0,0 +1,167 @@
# {{{ pub [CS ] SOCKS proxy gathering off phpBB [et al] sources and {DNS,R,...}BL matching
array unset {v:sites} {}
# {{{ RBL to query
set {v:sites:rbl} [list \
rbl.efnet.org \
dnsbl.swiftbl.net \
ircbl.ahbl.org \
dnsbl.dronebl.org \
tor.dnsbl.sectoor.de \
dnsbl.njabl.org]
# }}}
array unset {v:proxies}
array unset {v:proxies:rbl}
# {{{ dcsproxy.com
array set {v:sites} [list dcsproxy [list \
[list "http://www.dcsproxy.com/login.php?do=login" \
[list \
# vb_login_username "insectcrew" \
vb_login_lusername "szucsy" \
do "login" \
# vb_login_md5password "7e7cb40bdbfd8d4c512eda43e748b3ba" \
vb_login_md5password "966bf1eaaaf07917faa5192115a10988" \
# vb_login_md5password_utf "7e7cb40bdbfd8d4c512eda43e748b3ba" \
vb_login_md5password_utf "966bf1eaaaf07917faa5192115a10988" \
cookieuser 1 \
s "" \
] \
] \
"http://www.dcsproxy.com/socks-lists/" \
"http://www.dcsproxy.com/login.php?do=logout" \
{<div>.+?</div>} \
{<a href="(.+?)"} \
]]
# }}}
# {{{ proxy-heaven.blogspot.com
array set {v:sites} [list proxy-heaven [list \
[list] \
"http://proxy-heaven.blogspot.com/" \
"" \
{<h3 class=.+?>.+?</h3>} \
{(?i)href='(.+?socks.+?)'} \
]]
# }}}
set {v:filter} {:23|443|(?:[18]0)?8[08]|312[78]|6588|9050$}
# }}}
# {{{ pub [CS ] SOCKS proxy gathering off phpBB [et al] sources and {DNS,R,...}BL matching
setudef flag socks
array unset {v%cookies}
# {{{ bind evnt -|- loaded v%socks:ini
bind evnt -|- loaded v%socks:ini
proc v%socks:ini args {
global {v:sites}
foreach {- - tid} \
[join [lsearch -all -inline -regexp [utimers] {v%socks:daily}]] {
killutimer ${tid} }
foreach t [array names {v:sites}] {
foreach c [channels] {
if {![channel get ${c} socks]} { continue }
catch {utimer 86400 [list v%socks:daily ${c} ${t}]} ;# XXX tunable
}
}
}
# }}}
# {{{ utimer 86400 [list v%socks:daily [ ... ]]
proc v%socks:daily {c t} {
catch {v:socks * * * ${c} ${t}}
utimer 86400 [list v%socks:daily ${c} ${t}]
}
# }}}
# {{{ bind pub S|- .socks v:socks
bind pub S|- .socks v:socks
proc v:socks {n u h c t} {
global {v:sites} {v:proxies} {v:filter} {v%cookies}
if {![channel get ${c} socks]} { return }
if {![string length [set site [last [array get {v:sites} ${t}]]]]} {
v%blog "[v%ifx johne] unknown site `${t}'" ${c}; return }
set llogin [lindex ${site} 0]; set turl [lindex ${site} 1]; set lourl [lindex ${site} 2]
set tp0 [lindex ${site} 3]; set tp1 [lindex ${site} 4]
if { [llength ${llogin}] && \
![string length [last [array get {v%cookies} ${site}]]]} {
set lurl [lindex ${llogin} 0]; set lbody [lindex ${llogin} 1]
v%fetch -cookies POST ${t} ${lurl} ${lbody} }
set socks {}
foreach thr [regexp -all -inline ${tp0} [v%fetch -- GET ${t} ${turl}]] {
if {[regexp -- ${tp1} ${thr} {} thrurl]} {
set thtml [v%fetch -- GET ${t} ${turl}]
foreach {- s} [regexp -all -inline {\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+} ${thtml}] {
lappend socks ${s}
}
}
}
set socks [lsearch -not -all -inline -regexp ${socks} ${v:filter}]
if {![llength ${socks}]} { v%blog "[v%ifx johne/${t}] No socks found. FML" ${c} }\
else { v%blog "[v%ifx johne/${t}] Done. [llength ${socks}] socks found." ${c} }
array set {v:proxies} [list ${t} ${socks}]
if {[string length ${lourl}]} { catch {v%fetch -cookies GET ${lourl}}; }
return 1
}
# }}}
# {{{ bind pub S|- .matchbl v:socks:matchbl
bind pub S|- .matchbl v:socks:matchbl
proc v:socks:matchbl {n u h c t {zidx 0}} {
global {v:proxies} {v:proxies:rbl} {v:sites:rbl}
if {![channel get ${c} socks]} { return }
if {${zidx} == 0} { array set {v:proxies:rbl} [list ${t} [concat [last [array get {v:proxies} ${t}]]]] }
if {![llength [set proxies [last [array get {v:proxies:rbl} ${t}]]]]} {
v%blog "[v%ifx johne/rbl] don't have n e proxies for `${t}'" ${c}; return }
if {![string length [set zone [lindex ${v:sites:rbl} ${zidx}]]]} { return }
set nproxies [llength ${proxies}]; set n 0
v%blog "[v%ifx johne/rbl] ${t}: Matching ${nproxies} proxies against ${zone}" ${c}
array set {v:proxies:rbl} [list ${t} {}]
foreach ip ${proxies} {
incr n
if {[catch {set ha [apply format [join [list %d.%d.%d.%d [lreverse [scan ${ip} %d.%d.%d.%d]]]]].${zone}}] != 0} {
if {${n} >= ${nproxies}} {
v%dns:rbl - - - ${c} ${t} - ${zone} [incr zidx] [list ${n} ${h} ${u} ${c} ${t}]
}
} elseif {${n} >= ${nproxies}} {
dnslookup ${ha} \
v%dns:rbl ${c} ${t} ${ip} ${zone} [incr zidx] \
[list ${n} ${h} ${u} ${c} ${t}]
} else { dnslookup ${ha} v%dns:rbl ${c} ${t} ${ip} }
}
}
# }}}
# {{{ Ancillary
proc v%fetch {{cookies ""} {method ""} site url {body ""}} {
global {v%cookies}
set method [string tolower ${method}]
set cookie [last [array get {v%cookies} ${site}]]
# N.B. Tcl is the most worthless language there is
set html [apply ::httpx::${method} \
[list -headers ${url} [list Cookie [list ${cookie}]] ${body}]]
set status [lindex ${html} 0]
if {[string first 20 ${status} 0] != 0 && \
[string first 30 ${status} 0] != 0} { return -code return } ;# TODO
if {${cookies} == "-cookies"} {
set hdr [lindex ${html} 1]; set cookies ""
foreach idx [lsearch -all -regexp ${hdr} {Set-Cookie}] {
append cookies "[lindex ${hdr} [expr ${idx} + 1]]; "
}; if {[string length ${cookies}]} {
array set {v%cookies} [list ${site} ${cookies}] }
}; last ${html}
}
proc v%dns:rbl {ip host s c t oip {zone ""} {last 0} {pargs ""}} {
global {v:proxies:rbl}
if {${last}} {
v%dns:rbl:fini ${t} ${c} ${zone}; v:socks:matchbl - - - ${c} ${t} ${last}
} elseif {!${s}} { array set {v:proxies:rbl} [list ${t} [concat [last [array get {v:proxies:rbl} ${t}]] ${oip}]] }
}
proc v%dns:rbl:fini {t c zone} {
global {v:proxies:rbl}
set n [llength [last [array get {v:proxies:rbl} ${t}]]]
v%blog "[v%ifx johne/rbl] ${t}!${zone}: ${n} unlisted." ${c}
}
# }}}
# }}}
# }}}

21
muhstik/prox/tor-enode.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# <http://www.sectoor.de/tor.php>
# -- by vxp
#
hname="${1:?missing hostname}"
nick="${2:?missing nickname}"
for _addr in `dnsip ${hname} 2>/dev/null`
do
host -t TXT `echo "${_addr}" |\
awk -F. '{print $4 "." $3 "." $2 "." $1; }'`.tor.dnsbl.sectoor.de \
>/dev/null 2>&1
[ $? -eq 0 ] && { echo "${2} is a Tor using faggot (listed in sectoor's Tor DNSBL)"; };
done
exit 1;
# vim:ts=8 sw=8 noexpandtab

1938
muhstik/proxies.txt Normal file

File diff suppressed because it is too large Load Diff

225
muhstik/servers Normal file
View File

@ -0,0 +1,225 @@
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100
irc.gamesurge.net:6667 100

225
muhstik/servers6 Normal file
View File

@ -0,0 +1,225 @@
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100
irc.freenode.net:6667 100

4
muhstik/shuffle.sh Normal file
View File

@ -0,0 +1,4 @@
[ $# -ne 1 ] && { print "Try again."; exit 1; }
tmpfile="shuffled.tmp"
shuf $1 > $tmpfile
mv $tmpfile $1

2114
muhstik/socks4.txt Normal file

File diff suppressed because it is too large Load Diff

2113
muhstik/socks5.txt Normal file

File diff suppressed because it is too large Load Diff

1418
muhstik/src/clone.c Normal file

File diff suppressed because it is too large Load Diff

1022
muhstik/src/control.c Normal file

File diff suppressed because it is too large Load Diff

362
muhstik/src/init.c Normal file
View File

@ -0,0 +1,362 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2003, roadr (bigmac@home.sirklabs.hu) */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../include/init.h"
#include "../include/string.h"
#include "../include/lists.h"
#include "../include/print.h"
/* }}} */
/*{{{ Global variables */
char *hostname;
config_t conf;
char *channel[MAX_CHANS];
char *chankey[MAX_CHANS];
pthread_attr_t attr;
pthread_mutex_t mutex[MAX_MUTEX];
/* }}} */
/* {{{ check_options() */
void check_options()
{
int i;
for (i = 0; i < PROXYS && !conf.h[i][0]; ++i);
{
if (i == PROXYS && !conf.direct[0])
{
puts("You must supply a way of connection (proxy, socks, etc).");
exit(EXIT_FAILURE);
}
}
for (i = 0; i < PROXYS; ++i)
{
if (conf.h[i][0] && !conf.s[i][0])
{
puts("You must supply a server list for each proxy list.");
exit(EXIT_FAILURE);
}
}
for (i = 0; i < PROXYS; ++i)
{
if (!conf.h[i][0] && conf.s[i][0])
{
puts("You must supply a proxy list for each server list.");
exit(EXIT_FAILURE);
}
}
if (conf.use_wordlist && !conf.nicks[0])
{
puts("No nicknames to use.");
exit(EXIT_FAILURE);
}
}
/* }}} */
/* {{{ init_*() */
void init_threads()
{
int i;
if (pthread_attr_init(&attr))
{
puts("pthread_attr_init failed");
exit(EXIT_FAILURE);
}
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
{
puts("pthread_attr_setdetachstate failed");
exit(EXIT_FAILURE);
}
for (i = 0; i < MAX_MUTEX; ++i)
{
if (pthread_mutex_init(&mutex[i], NULL))
{
puts("pthread_mutex_init failed");
exit(EXIT_FAILURE);
}
}
}
void init_hostname()
{
char name[MEDBUF];
if (gethostname(name, sizeof(name)) == -1)
{
print_error("gethostname");
exit(EXIT_FAILURE);
}
StrFirstToken(name);
hostname = StrDuplicate(name);
}
void init_options(char **argv)
{
FILE *config, *f;
unsigned i;
unsigned j;
char buffer[MEDBUF];
char parm[MEDBUF];
struct
{
char *arg;
int *ptr;
} init_int[] = {
{ "load", &conf.load },
{ "group", &conf.group },
{ "clones", &conf.max_clones },
{ "wait", &conf.wait_socks },
{ "rewind", &conf.rewind_socks },
{ "timeout", &conf.timeout },
{ "max_reco", &conf.max_reco },
{ "wait_reco", &conf.wait_reco },
{ "no_restricted", &conf.no_restricted },
{ "scan", &conf.scan },
{ "help", &conf.help },
{ "verbose", &conf.verbose },
{ "debug", &conf.debug },
{ "nocolor", &conf.nocolor },
{ "dalnet", &conf.dalnet },
{ "using_wordlist", &conf.use_wordlist },
{ "nick_length", &conf.nick_length },
{ "ident_length", &conf.ident_length },
{ "real_length", &conf.real_length },
{ "rejoin", &conf.rejoin },
{ "multi_op", &conf.multi_op },
{ "multi_kick", &conf.multi_kick },
{ "multi_deop", &conf.multi_deop },
{ "aggressive", &conf.aggressive },
{ "peace", &conf.peace },
{ "repeat", &conf.repeat },
{ "notice", &conf.notice },
/* { "max_conns", &conf.max_conns }, */
{ NULL, NULL }
};
struct
{
char *arg;
FILE **ptr;
short min;
short max;
} init_list[] = {
{ "sock4_list", conf.h[SOCKS4], 0, MAX_GROUPS },
{ "sock4_server_list", conf.s[SOCKS4], 0, MAX_GROUPS },
{ "sock5_list", conf.h[SOCKS5], 0, MAX_GROUPS },
{ "sock5_server_list", conf.s[SOCKS5], 0, MAX_GROUPS },
{ "proxy_list", conf.h[PROXY], 0, MAX_GROUPS },
{ "proxy_server_list", conf.s[PROXY], 0, MAX_GROUPS },
{ "cisco_list", conf.h[CISCO], 0, MAX_GROUPS },
{ "cisco_server_list", conf.s[CISCO], 0, MAX_GROUPS },
{ "vhost_list", conf.h[VHOST], 0, MAX_GROUPS },
{ "vhost_server_list", conf.s[VHOST], 0, MAX_GROUPS },
{ "direct_server_list", conf.direct, 0, 2 },
{ NULL, NULL, 0, 0 }
};
struct
{
char *arg;
char **ptr;
short min;
short max;
} init_save[] = {
{ "sock4_save", conf.g[SOCKS4], 0, MAX_GROUPS },
{ "sock5_save", conf.g[SOCKS5], 0, MAX_GROUPS },
{ "proxy_save", conf.g[PROXY], 0, MAX_GROUPS },
{ "vhost_save", conf.g[VHOST], 0, MAX_GROUPS },
{ "cisco_save", conf.g[CISCO], 0, MAX_GROUPS },
{ NULL, NULL, 0, 0 }
};
struct
{
char *arg;
char **save;
char **ptr;
int max;
} init_read[] = {
{ "aop_list", &conf.userlist[AOP], conf.aop, MAX_AOPS },
{ "jupe_list", &conf.userlist[JUPE], conf.jupe, MAX_JUPES },
{ "prot_list", &conf.userlist[PROT], conf.prot, MAX_PROTS },
{ "shit_list", &conf.userlist[SHIT], conf.shit, MAX_SHITS },
{ "nicks", NULL, conf.nicks, MAX_NICKS },
{ "idents", NULL, conf.idents, MAX_IDENTS },
{ "realnames", NULL, conf.names, MAX_NAMES },
{ NULL, NULL, NULL, 0 }
};
struct
{
char *arg;
char **ptr;
} init_str[] = {
{ "onstart", &conf.batch },
{ "chan", channel },
{ "motd", &conf.motd },
{ NULL, NULL }
};
/* Initialize the parameters */
conf.load = 2000;
conf.group = 1;
conf.timeout = 30;
conf.max_clones = 1;
conf.multi_kick = 1;
conf.multi_op = 4;
conf.multi_deop = 4;
conf.rejoin = 5;
conf.dalnet = 1;
conf.nick_length = 8;
conf.ident_length = 8;
conf.real_length = 8;
if (!(config = fopen(argv[1], "r")))
{
puts("Cannot open the config file.");
exit(EXIT_FAILURE);
}
while (!get_a_line(buffer, sizeof(buffer), config))
{
if (StrParam(parm, sizeof(parm), buffer, 0))
{
continue;
}
/* Initialize the integer parameters */
for (i = 0; init_int[i].arg; ++i)
{
if (!StrCompare(init_int[i].arg, parm))
{
if (!StrParam(parm, sizeof(parm), buffer, 1))
{
*init_int[i].ptr = atoi(parm);
break;
}
}
}
if (init_int[i].arg)
{
continue;
}
/* Initialize the file descriptors */
for (i = 0; init_list[i].arg; ++i)
{
if (!StrCompare(init_list[i].arg, parm))
{
if (init_list[i].min < init_list[i].max-1)
{
if (!StrParam(parm, sizeof(parm), buffer, 1))
{
j = init_list[i].min++;
if (!((init_list[i].ptr)[j] = fopen(parm, "r")))
{
printf("Cannot open a %s.\n", init_list[i].arg);
exit(EXIT_FAILURE);
}
break;
}
}
}
}
if (init_list[i].arg)
{
continue;
}
/* Initialize save filenames */
for (i = 0; init_save[i].arg; ++i)
{
if (!StrCompare(init_save[i].arg, parm))
{
if (init_save[i].min < init_save[i].max-1)
{
if (!StrParam(parm, sizeof(parm), buffer, 1))
{
j = init_save[i].min++;
(init_save[i].ptr)[j] = StrDuplicate(parm);
break;
}
}
}
}
if (init_save[i].arg)
{
continue;
}
/* Initialize the lists to read */
for (i = 0; init_read[i].arg; ++i)
{
if (!StrCompare(init_read[i].arg, parm))
{
if (!StrParam(parm, sizeof(parm), buffer, 1))
{
if (init_read[i].save)
{
*init_read[i].save = StrDuplicate(parm);
}
if ((f = fopen(parm, "r")))
{
fill_table(init_read[i].ptr, init_read[i].max, f);
fclose(f);
}
else if (!init_read[i].save)
{
printf("Cannot open the %s.\n", init_read[i].arg);
exit(EXIT_FAILURE);
}
break;
}
}
}
if (init_read[i].arg)
{
continue;
}
/* Initialize the string parameters */
for (i = 0; init_str[i].arg; ++i)
{
if (!StrCompare(init_str[i].arg, parm))
{
if (!StrParam(parm, sizeof(parm), buffer, 1))
{
*init_str[i].ptr = StrDuplicate(parm);
break;
}
}
}
if (init_str[i].arg)
{
continue;
}
}
fclose(config);
}
/* }}} */

363
muhstik/src/lists.c Normal file
View File

@ -0,0 +1,363 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <stdio.h>
#include <stdlib.h>
#include "../include/lists.h"
#include "../include/string.h"
/* }}} */
/* {{{ File functions */
/* {{{ int occur_file(char *s, char *list) */
int occur_file(char *s, char *list)
{
char buffer[BIGBUF];
register int i = 0;
FILE *f;
if ((f = fopen(list, "r")))
{
while (fgets(buffer, sizeof(buffer), f))
{
if (!StrCompare(buffer, s))
{
++i;
}
fclose(f);
}
}
return i;
}
/* }}} */
/* {{{ void add_file(char *s, char *list) */
void add_file(char *s, char *list)
{
FILE *f;
if (!(f = fopen(list, "a+")))
{
return;
}
fputs(s, f);
fclose(f);
}
/* }}} */
/* {{{ int file_length(FILE *f) */
int file_length(FILE *f)
{
register int i = 0;
int c = 0;
while ((c=fgetc(f)) != EOF)
{
if (c == '\n')
{
++i;
}
}
rewind(f);
return i;
}
/* }}} */
/* {{{ int get_a_line(char *s, int z, FILE *f) */
int get_a_line(char *s, int z, FILE *f)
{
do
{
if (!fgets(s, z, f))
{
return 1;
}
}
while (s[0]=='#' || s[0]=='[' || s[0]==10);
return 0;
}
/* }}} */
/* }}} */
/* {{{ Table functions */
/* {{{ int add_table(char *toadd, char **list, int max) */
int add_table(char *toadd, char **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list == NULL)
{
*list = StrDuplicate(toadd);
return i;
}
}
return -1;
}
/* }}} */
/* {{{ int remove_table(char *torm, char **list, int max) */
int remove_table(char *torm, char **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list && !StrCompare(*list, torm))
{
free(*list);
*list = NULL;
return 0;
}
}
return 1;
}
/* }}} */
/* {{{ void update_table(char *from, char *to, char **list, int max) */
void update_table(char *from, char *to, char **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list && !StrCompare(from, *list))
{
free(*list);
*list = StrDuplicate(to);
return;
}
}
}
/* }}} */
/* {{{ void update_pattern_table(char *from, char *to, char **list, int max) */
void update_pattern_table(char *from, char *to, char **list, int max)
{
register int i;
char buffer[MEDBUF+1];
for (i = 0; i < max; ++i, ++list)
{
if ((*list) && (sscanf(*list, "%"MEDBUF_TXT"[^!]", buffer) == 1) && (!StrCompare(from, buffer)))
{
snprintf(buffer, sizeof(buffer), "%s%s", to, strchr(*list, '!'));
free(*list);
*list = StrDuplicate(buffer);
return;
}
}
}
/* }}} */
/* {{{ int occur_table(char *s, char **list, int max) */
int occur_table(char *s, char **list, int max)
{
register int i;
int k = 0;
for (i = 0; i < max; ++i, ++list)
{
if (*list && !StrCompare(*list, s))
{
++k;
}
}
return k;
}
/* }}} */
/* {{{ void fill_table(char **list, int max, FILE *f) */
void fill_table(char **list, int max, FILE *f)
{
register int i;
char parm[MEDBUF];
for (i = 0; i < max && fgets(parm, sizeof(parm), f); ++i)
{
sscanf(parm, "%[^\r\n]", parm);
list[i] = StrDuplicate(parm);
}
}
/* }}} */
/* {{{ void clear_table(char **list, int max) */
void clear_table(char **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list)
{
free(*list);
*list = NULL;
}
}
}
/* }}} */
/* {{{ int match_table(char *s, char **list, int max) */
int match_table(char *s, char **list, int max)
{
register int i;
char parm[MEDBUF];
for (i = 0; i < max; ++i, ++list)
{
if (*list && !StrParam(parm, sizeof(parm), *list, 0))
{
if (match_pattern(parm, s))
{
return i;
}
}
}
return -1;
}
/* }}} */
/* }}} */
/* {{{ Queue functions */
/* {{{ int add_gen_queue(void *d, cmp_fun *cmp, queue *list) */
int add_gen_queue(void *d, cmp_fun *cmp, queue *list)
{
queue s;
queue p1 = NULL;
queue p2 = NULL;
s = xmalloc(sizeof(struct st_list));
s->data = d;
s->next = NULL;
if (*list == NULL)
{
*list = s;
return 0;
}
for (p2 = *list; p2; p2 = p2->next)
{
if (cmp && !cmp(p2->data, d))
{
free(s->data);
free(s);
return 1;
}
p1 = p2;
}
p1->next = s;
return 0;
}
/* }}} */
/* {{{ inline int add_queue(char *s, queue *list) */
inline int add_queue(char *s, queue *list)
{
return add_gen_queue(StrDuplicate(s), NULL, list);
}
/* }}} */
/* {{{ inline int uniq_add_queue(char *s, queue *list) */
inline int uniq_add_queue(char *s, queue *list)
{
return add_gen_queue(StrDuplicate(s), StrCompare, list);
}
/* }}} */
/* {{{ int remove_queue(char *d, queue *list) */
int remove_queue(char *d, queue *list)
{
queue p1 = NULL;
queue p2 = NULL;
if (*list == NULL)
{
return 1;
}
if (!StrCompare((*list)->data, d))
{
free_cell(list);
return 0;
}
for (p2 = *list; p2; p2 = p2->next)
{
if (!StrCompare(p2->data, d))
{
p1->next = p2->next;
free(p2->data);
free(p2);
return 0;
}
p1 = p2;
}
return 1;
}
/* }}} */
/* {{{ void update_queue(char *old, char *new, queue *list) */
void update_queue(char *old, char *new, queue *list)
{
queue p;
for (p = *list; p; p = p->next)
{
if (!StrCompare(p->data, old))
{
free(p->data);
p->data = StrDuplicate(new);
}
}
}
/* }}} */
/* {{{ int occur_queue(char *s, queue *list) */
int occur_queue(char *s, queue *list)
{
queue p;
int k = 0;
for (p = *list; p; p = p->next)
{
if (!StrCompare(p->data, s))
{
++k;
}
}
return k;
}
/* }}} */
/* }}} */
/* {{{ Cell functions */
/* {{{ void free_cell(queue *list) */
void free_cell(queue *list)
{
queue tmp;
if (*list == NULL)
{
return;
}
tmp = (*list)->next;
free((*list)->data);
free(*list);
*list = tmp;
}
/* }}} */
/* {{{ void rotate_cell(queue *list) */
void rotate_cell(queue *list)
{
queue cell;
void *data;
cell = (*list)->next;
data = (*list)->data;
free(*list);
*list = cell;
add_gen_queue(data, NULL, list);
}
/* }}} */
/* }}} */
/* {{{ void clear_queue(queue *list) */
void clear_queue(queue *list)
{
while (*list)
{
free_cell(list);
}
}
/* }}} */

316
muhstik/src/load.c Normal file
View File

@ -0,0 +1,316 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2003, roadr (bigmac@home.sirklabs.hu) */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "../include/string.h"
#include "../include/lists.h"
#include "../include/print.h"
#include "../include/load.h"
/* }}} */
/* {{{ External variables */
extern clone_t *cl[];
extern config_t conf;
extern const char *strtype[];
extern pthread_mutex_t mutex[];
/* }}} */
/* {{{ randget() */
void randget(clone_t *clone, char **dest, size_t destlen, int uselist, char **list, int max)
{
register unsigned int i; /* ``unsigned'' is not needed, stops a warning when compiled with -Wsign-compare */
char *tmp;
/* Alphabet used to make random words */
static char charset[] = "abcdefghijklmnopqrstuvwxyz";
static size_t len;
len = strlen(charset);
tmp = (char *)xmalloc(destlen + 1);
if (uselist && list[0])
{
for (i = 0; i < MAX_NICKS && list[i]; ++i) {}
StrCopy(tmp, list[random() % i], destlen + 1);
}
else
{
for (i = 0; i < destlen; ++i)
{
tmp[i] = charset[random() % len];
}
}
tmp[destlen] = 0;
*dest = tmp;
}
/* }}} */
/* {{{ Loading functions */
int load_clone(clone_t *go)
{
clone_t **pcl;
register int id;
/* Get a free entry in cl[] */
for (id = 0, pcl = cl; *pcl; ++id, ++pcl)
{
if (id == MAX_CLONES-1)
{
return 1;
}
}
/* Allocate memory for a new clone structure */
if (!(*pcl = (clone_t *)malloc(sizeof(clone_t))))
{
print_error("malloc");
return 1;
}
/* Copy the current clone parameters in it */
memcpy(*pcl, go, sizeof(clone_t));
/* The id is useful to free the structure on exit */
(*pcl)->id = id;
/* Launch the clone */
if (main_clone(*pcl))
{
free_clone(*pcl);
}
return 0;
}
int load_host(int t, char *host, int proxy_port, char *server, int server_port, char *pass, char *ident, char *save, int mode)
{
clone_t go;
/* Initialize the current clone structure */
memset(&go, 0, sizeof(clone_t));
memset(&go.buffer, 0, sizeof(go.buffer));
memset(&go.lastbuffer, 0, sizeof(go.lastbuffer));
go.sock = -1;
go.type = t;
go.mode = mode;
if (go.type != NOSPOOF)
{
go.proxy = StrDuplicate(host);
go.proxy_port = proxy_port;
}
go.server = StrDuplicate(server);
go.server_port = server_port;
go.server_pass = StrDuplicate(pass);
go.server_ident = StrDuplicate(ident);
go.save = StrDuplicate(save);
/* Make the clone's {nick,ident,realname} from a wordlist or randomly. */
randget(&go, &go.nick, conf.nick_length, conf.use_wordlist, conf.nicks, MAX_NICKS);
randget(&go, &go.ident, conf.ident_length, 1, conf.idents, MAX_IDENTS);
randget(&go, &go.real, conf.real_length, 1, conf.names, MAX_NAMES);
return load_clone(&go);
}
void loadlist(int t, FILE *hosts, FILE *servers, char *save)
{
int ret;
int i = 0;
int k = 0;
int l = 0;
int max_server = 0;
int max_proxys = 0;
char server[MEDBUF+1];
char *serv = NULL;
char *pass = NULL;
char *ident = NULL;
int server_port;
char proxy[MEDBUF+1];
int proxy_port;
char buffer[MEDBUF+1];
char parm[MINIBUF];
if (!conf.wait_socks && hosts)
{
max_proxys = file_length(hosts);
}
while (1)
{
if (i == 0)
{
/* Get the next server on the current server list */
if (!fgets(buffer, sizeof(buffer), servers))
{
return;
}
switch (sscanf(buffer, "%"MEDBUF_TXT"[^:\r\n]:%d %d", server, &server_port, &max_server))
{
default:
print(1, 0, 0, "No line to read");
return;
case 1:
print(1, 0, 0, "%s: server error (host:port)", server);
return;
case 2:
print(1, 0, 0, "%s: server error (no max)", server);
return;
case 3:
print(1, 3, 0, "%s server: %s:%d [max=%d]", strtype[t], server, server_port, max_server);
if (!StrParam(parm, sizeof(parm), buffer, 2))
{
pass = StrDuplicate(parm);
}
if (!StrParam(parm, sizeof(parm), buffer, 3))
{
ident = StrDuplicate(parm);
}
if (t != NOSPOOF && conf.rewind_socks)
{
rewind(hosts);
}
break;
}
if (t == NOSPOOF && max_server <= 0)
{
print(1, 0, 0, "%s: server error (max must be > 0)", server);
return;
}
serv = StrDuplicate(server);
}
/* Get the next proxy on the current proxy list, if needed */
if (t != NOSPOOF && k == 0)
{
while (get_a_line(buffer, sizeof(buffer), hosts))
{
if (conf.wait_socks)
{
sleep(2);
}
else
{
return;
}
}
sscanf(buffer, "%"MEDBUF_TXT"s", proxy);
if (t != VHOST)
{
if (strchr(proxy,':'))
{
sscanf(proxy, "%*[^:]:%d", &proxy_port); /* XXX: What if ``(t == VHOST)''? -- Leon */
sscanf(proxy, "%[^:]", proxy);
}
else switch (t) /* set a default port */
{
case CISCO:
proxy_port = 23;
break;
case SOCKS4:
case SOCKS5:
proxy_port = 1080;
break;
case PROXY:
print(1, 0, 0, "%s: proxy error (host:port)", proxy);
proxy_port = 8080;
break;
}
}
}
while ((max_server <= 0 || i < max_server) && (t == NOSPOOF || k < conf.max_clones))
{
pthread_mutex_lock(&mutex[0]);
ret = load_host(t, proxy, proxy_port, serv, server_port, pass, ident, save, M_NORMAL);
pthread_mutex_unlock(&mutex[0]);
if (ret)
{
pthread_exit(0);
}
++i, ++k, ++l;
if (l == conf.group && conf.load > 0)
{
usleep(conf.load * 1000), l = 0;
}
}
if (i == max_server)
{
i = 0;
}
if (k == conf.max_clones)
{
k = 0;
}
if (!conf.wait_socks && hosts && max_server <= 0)
{
if (i == max_proxys * conf.max_clones)
{
i = 0;
}
}
}
}
void load1(int t, FILE *hosts, FILE *servers, char *save)
{
loadlist(t, hosts, servers, save);
if (conf.verbose)
{
print(1, 0, 0, "all %ss loaded.", strtype[t]);
}
}
void load2(int t, FILE **p1, FILE **p2, char **p3)
{
FILE **fhost;
FILE **fserv;
char **csave;
for (fhost = p1, fserv = p2, csave = p3; *fhost; ++fhost, ++fserv, ++csave)
{
load1(t, *fhost, *fserv, *csave);
}
}
void *load_all(void *arg)
{
int i;
for (i = 0; i < PROXYS; ++i)
{
if (conf.h[i][0])
{
load2(i, conf.h[i], conf.s[i], conf.g[i]);
}
}
if (conf.direct[0])
{
load1(NOSPOOF, NULL, conf.direct[0], NULL);
}
return NULL;
}
/* }}} */

277
muhstik/src/mass.c Normal file
View File

@ -0,0 +1,277 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "../include/mass.h"
#include "../include/control.h"
#include "../include/net.h"
#include "../include/string.h"
#include "../include/lists.h"
/* }}} */
/* {{{ Variables */
/* {{{ External Variables */
extern char *channel[];
extern char *broth[];
extern clone_t *cl[];
extern config_t conf;
extern queue names_op[];
extern queue names[];
/* }}} */
/*{{{ Global variables */
int mass_ch;
int mass_mode;
char *mass_reas;
char *mass_server;
/* }}} */
/* }}} */
/* {{{ Massmode functions */
/* {{{ multimode() */
void multimode(clone_t *clone, char *chan, char *sign, int n, char *nicks, int uniq)
{
char modes[MINIBUF];
int i;
memset(modes, 0, sizeof(modes));
StrCat(modes, " ", sizeof(modes));
StrCat(modes, sign, sizeof(modes));
for (i = 0; i < n; ++i)
{
StrCat(modes, "o", sizeof(modes));
}
if (uniq)
{
send2server(clone, "MODE %s%s%s\n", chan, modes, nicks);
}
else
{
send_sock(clone->sock, "MODE %s%s%s\n", chan, modes, nicks);
}
}
/* }}} */
/* {{{ (de)opping and kicking functions */
/* TODO: Deop +{h,a,q}, if possible. */
void massdeop(clone_t *clone, int chid)
{
int i;
int n = 0;
char nicks[BIGBUF];
queue *list;
memset(nicks, 0, sizeof(nicks));
list = &names_op[chid];
for (i = 0; *list && i < conf.multi_deop; ++i)
{
if (is_enemy((*list)->data))
{
StrCat(nicks, " ", sizeof(nicks));
StrCat(nicks, (*list)->data, sizeof(nicks));
++n;
}
rotate_cell(list);
}
if (n > 0)
{
multimode(clone, channel[chid], "-", n, nicks, 1);
}
}
void massop(clone_t *clone, int chid)
{
register int i;
register int j;
clone_t **pcl;
char nicks[BIGBUF];
memset(nicks, 0, sizeof(nicks));
for (i = j = 0, pcl = cl; j < conf.multi_op && i < MAX_CLONES; ++i, ++pcl)
{
if ((*pcl) && (*pcl) != clone && (*pcl)->online && (*pcl)->needop[chid])
{
(*pcl)->needop[chid] = 0;
StrCat(nicks, " ", sizeof(nicks));
StrCat(nicks, (*pcl)->nick, sizeof(nicks));
++j;
}
}
if (j > 0)
{
multimode(clone, channel[chid], "+", j, nicks, 0);
}
}
void force_massop()
{
register int i;
char **pt;
clone_t **pcl;
clone_t *one;
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if ((*pcl) && (*pcl)->online && !(*pcl)->restricted && !(*pcl)->op[mass_ch] && (one = getop(mass_ch)))
{
op(one, mass_ch, (*pcl)->nick);
}
}
for (i = 0, pt = broth; i < MAX_BROTHERS; ++i, ++pt)
{
if ((*pt) && (one = getop(mass_ch)))
{
op(one, mass_ch, *pt);
}
}
}
void _masskick(clone_t *clone, int chid, queue **list)
{
int n;
char buffer[BIGBUF];
memset(buffer, 0, sizeof(buffer));
for (n = 0; **list && n < conf.multi_kick; ++n)
{
if (n > 0)
{
StrCat(buffer, ",", BIGBUF);
}
StrCat(buffer, (**list)->data, BIGBUF);
free_cell(*list);
}
kick(clone, chid, buffer, mass_reas ? mass_reas : NULL, 0);
}
void _massdeop(clone_t *clone, int chid, queue **list)
{
int i;
char nicks[BIGBUF];
memset(nicks, 0, sizeof(nicks));
for (i = 0; **list && i < conf.multi_deop; ++i)
{
StrCat(nicks, " ", sizeof(nicks));
StrCat(nicks, (**list)->data, sizeof(nicks));
free_cell(*list);
}
if (i > 0)
{
multimode(clone, channel[chid], "-", i, nicks, 0);
}
}
/* }}} */
/* {{{ massdo()ing functions */
void massdo(queue *list, int chid, int mode)
{
int id;
clone_t **pcl;
int n;
for (n = 0; *list && n < 10; ++n)
{
for (id = 0, pcl = cl; *list && id < MAX_CLONES; ++id, ++pcl)
{
if (is_op(*pcl, chid))
{
switch (mode)
{
case MK:
_masskick(*pcl, chid, &list);
break;
case MD:
_massdeop(*pcl, chid, &list);
break;
case MKB:
kickban(*pcl, (*list)->data);
free_cell(list);
break;
}
(*pcl)->lastsend = time(NULL);
}
} /* bracket might be after the `usleep()' -- Leon */
usleep(500000);
}
}
void takeover(queue *list)
{
register int i;
clone_t **pcl;
for (i = 0, pcl = cl; *list && i < MAX_CLONES; ++i, ++pcl)
{
if ((*pcl) && (*pcl)->online && (*pcl)->server == mass_server)
{
send_irc_nick(*pcl, (*list)->data);
free_cell(list);
}
}
}
void *init_massdo(int chid, int mode)
{
queue list1 = NULL;
queue list2 = NULL;
queue plist;
for (plist = names_op[chid]; plist; plist = plist->next)
{
if (mode == TO || is_enemy(plist->data))
{
add_queue(plist->data, &list1);
}
}
for (plist = names[chid]; plist; plist = plist->next)
{
if (mode != TO && mode != MD && is_enemy(plist->data))
{
add_queue(plist->data, &list2);
}
}
switch (mode)
{
case MKB:
case MK:
massdo(&list1, chid, mode);
massdo(&list2, chid, mode);
break;
case MD:
massdo(&list1, chid, mode);
break;
case TO:
takeover(&list1);
break;
}
clear_queue(&list1);
clear_queue(&list2);
return NULL;
}
/* }}} */
/* }}} */

469
muhstik/src/muhstik.c Normal file
View File

@ -0,0 +1,469 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <time.h>
#include "../include/muhstik.h"
#include "../include/clone.h"
#include "../include/proxy.h"
#include "../include/control.h"
#include "../include/print.h"
#include "../include/load.h"
#include "../include/string.h"
/* }}} */
/* {{{ Variables */
/* {{{ External variables */
extern clone_t *cl[];
extern const char *strtype[];
extern char *channel[];
extern pthread_mutex_t mutex[];
extern pthread_attr_t attr;
extern int mass_ch;
extern int maxsock;
extern config_t conf;
extern char *hostname;
/* }}} */
/* {{{ Global Variables */
time_t t0;
pid_t pid;
/* }}} */
/* }}} */
/* {{{ save_list() */
void save_list(char *filename, char **list, int max)
{
int i;
FILE *f;
if ((f = fopen(filename, "w")))
{
for (i = 0; i < max; ++i)
{
if (list[i])
{
fprintf(f, "%s\n", list[i]);
}
}
fclose(f);
}
}
/* }}} */
/* {{{ main() functions */
void main_exit()
{
if (conf.userlist[AOP])
{
save_list(conf.userlist[AOP], conf.aop, MAX_AOPS);
}
if (conf.userlist[JUPE])
{
save_list(conf.userlist[JUPE], conf.jupe, MAX_JUPES);
}
if (conf.userlist[PROT])
{
save_list(conf.userlist[PROT], conf.prot, MAX_PROTS);
}
if (conf.userlist[SHIT])
{
save_list(conf.userlist[SHIT], conf.shit, MAX_SHITS);
}
exit(EXIT_SUCCESS);
}
void segfault(int sig)
{
puts("Segmentation fault: blog it.");
exit(EXIT_FAILURE);
}
int main(int argc, char **argv)
{
pthread_t tid;
printf("muhstik %s, Copyright (C) 2001-2003, Louis Bavoil\n", VERSION);
printf(" Copyright (C) 2009-2011, Leon Kaiser\n");
printf("This is free software. See the LICENSE file for more details.\n");
if (argc < 2)
{
printf("Usage: %s <config file>\n", argv[0]);
exit(EXIT_FAILURE);
}
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGALRM, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
signal(SIGSEGV, &segfault);
signal(SIGINT, SIG_IGN);
t0 = time(NULL);
pid = getpid();
srandom(pid);
init_options(argv);
check_options();
init_threads();
init_hostname();
if (conf.motd)
{
print_motd(1);
}
if (conf.help)
{
usage(1);
}
if (pthread_create(&tid, &attr, load_all, NULL))
{
puts("pthread_create() failed");
main_exit();
}
if (conf.batch)
{
read_batch();
}
main_loop();
return 0;
}
/* }}} */
/* {{{ read_batch() */
void read_batch()
{
FILE *f;
char buffer[BIGBUF];
if (!(f = fopen(conf.batch, "r")))
{
print(1, 0, 0, "Cannot open the file `%s.'", conf.batch);
return;
}
while (1)
{
if (!fgets(buffer, sizeof(buffer), f))
{
return;
}
interpret(buffer, 0);
}
fclose(f);
}
/* }}} */
/* {{{ sock2clone() */
clone_t *sock2clone(int sock)
{
register int i;
clone_t **pcl;
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if (*pcl && (*pcl)->sock == sock)
{
return *pcl;
}
}
return NULL;
}
/* }}} */
/* {{{ init_gateway() */
int init_gateway(clone_t *clone)
{
int ret = EXIT;
clone->host = clone->server;
clone->port = clone->server_port;
switch (clone->type)
{
case SOCKS4:
ret = init_socks4(clone);
break;
case SOCKS5:
ret = init_socks5(clone);
break;
case PROXY:
ret = init_proxy(clone);
break;
case CISCO:
ret = WAIT_CISCO;
break;
}
return ret;
}
/* }}} */
/* {{{ Read/write functions */
void write_ready(int sok)
{
clone_t *clone;
unsigned int len = sizeof(int);
if ((clone = sock2clone(sok)))
{
if (getsockopt(sok, SOL_SOCKET, SO_ERROR, &errno, &len))
{
print_error("getsockopt");
clone->status = EXIT;
return;
}
if (errno != 0)
{
print_error("connect");
clone->status = EXIT;
return;
}
if (clone->type != NOSPOOF)
{
print(1, 0, 0, "%s connect()ed: host=%s server=%s", strtype[clone->type], clone->proxy, clone->server);
}
else
{
print(1, 0, 0, "direct connect()ed: server=%s", clone->server);
}
if (clone->type == NOSPOOF || clone->type == VHOST)
{
clone->status = init_irc(clone);
}
else
{
clone->status = init_gateway(clone);
}
return;
}
}
int read_irc(clone_t *clone)
{
char *buf;
char *line;
int i;
int n;
i = strlen(clone->buffer);
n = sizeof(clone->buffer) - 1 - i;
if (recv(clone->sock, clone->buffer + i, n, 0) <= 0)
{
buf = clone->lastbuffer;
if (buf[strlen(buf)-1] != '\n')
{
StrCat(buf, "\n", sizeof(clone->lastbuffer));
}
if (parse_deco(clone, buf))
{
return EXIT;
}
return WAIT_CONNECT;
}
else
{
buf = clone->buffer;
while (strchr(buf,'\n'))
{
line = strsep(&buf, "\r\n");
if (buf == NULL)
{
buf = "";
}
snprintf(clone->lastbuffer, sizeof(clone->lastbuffer), "%s\n", line);
parse_irc(clone, clone->lastbuffer);
}
StrCopy(clone->lastbuffer, clone->buffer, sizeof(clone->lastbuffer));
StrCopy(clone->buffer, buf, sizeof(clone->buffer));
}
if (conf.no_restricted && clone->restricted)
{
return EXIT;
}
return WAIT_IRC;
}
void read_stdin()
{
char buffer[BIGBUF];
memset(buffer, 0, sizeof(buffer));
if (!fgets(buffer, sizeof(buffer), stdin))
{
return;
}
interpret(buffer, 1);
}
void read_ready(int sok)
{
clone_t *clone;
int ret = EXIT;
if (sok == 0)
{
read_stdin();
return;
}
if ((clone = sock2clone(sok)))
{
switch (clone->status)
{
case WAIT_SOCKS4:
ret = read_socks4(clone);
break;
case WAIT_SOCKS5_1:
ret = init_read_socks5(clone);
break;
case WAIT_SOCKS5_2:
ret = read_socks5(clone);
break;
case WAIT_PROXY:
ret = read_proxy(clone);
break;
case WAIT_CISCO:
ret = read_cisco(clone);
break;
case WAIT_IRC:
ret = read_irc(clone);
break;
}
if (ret == WAIT_IDENT)
{
ret = init_irc(clone);
}
clone->status = ret;
return;
}
}
/* }}} */
/* {{{ fill_fds() */
void fill_fds(fd_set *rfds, fd_set *wfds)
{
clone_t **pcl;
register int i;
time_t now;
now = time(NULL);
FD_SET(0, rfds);
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if (*pcl)
{
if ((*pcl)->rejoin_time > 0)
{
if (!channel[mass_ch])
{
(*pcl)->rejoin_time = 0;
}
else if ((*pcl)->rejoin_time <= now)
{
join(*pcl, channel[mass_ch]);
(*pcl)->rejoin_time = 0;
}
}
if ((*pcl)->alarm > 0)
{
if ((*pcl)->alarm > now)
{
continue;
}
(*pcl)->alarm = 0;
}
switch ((*pcl)->status)
{
case EXIT:
/* Connection closed */
free_clone(*pcl);
break;
case WAIT_CONNECT:
if (now-(*pcl)->start > conf.timeout)
{
/* Connection timeout */
free_clone(*pcl);
break;
}
FD_SET((*pcl)->sock, wfds);
break;
default:
FD_SET((*pcl)->sock, rfds);
break;
}
}
}
}
/* }}} */
/* {{{ main_loop() */
void main_loop()
{
fd_set rfds;
fd_set wfds;
register int sok;
struct timeval tv;
while (1)
{
FD_ZERO(&rfds);
FD_ZERO(&wfds);
pthread_mutex_lock(&mutex[0]);
fill_fds(&rfds, &wfds);
pthread_mutex_unlock(&mutex[0]);
tv.tv_sec = 1;
tv.tv_usec = 0;
if (select(maxsock + 1, &rfds, &wfds, NULL, &tv) == -1)
{
print_error("select");
main_exit();
}
for (sok = 0; sok <= maxsock; ++sok)
{
if (FD_ISSET(sok, &wfds))
{
pthread_mutex_lock(&mutex[0]);
write_ready(sok);
pthread_mutex_unlock(&mutex[0]);
}
}
for (sok = maxsock; sok >= 0; --sok)
{
if (FD_ISSET(sok, &rfds))
{
pthread_mutex_lock(&mutex[0]);
read_ready(sok);
pthread_mutex_unlock(&mutex[0]);
}
}
}
}
/* }}} */

205
muhstik/src/net.c Normal file
View File

@ -0,0 +1,205 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include "../include/net.h"
#include "../include/proxy.h"
#include "../include/string.h"
#include "../include/print.h"
/* }}} */
/* {{{ Variables */
/* {{{ Global Variables */
int maxsock;
/* }}} */
/* }}} */
/* {{{ Hard-wired, compile-time constants */
#ifndef INADDR_NONE
#define INADDR_NONE -1
#endif
#define MAX_HOSTNAME 256
/* }}} */
/* {{{ lookup_*() */
/* ``he->h_addrtype == AF_INET6`` */
int lookup_host(char *host, struct in_addr *addr)
{
struct hostent *he;
if ((he = gethostbyname(host)) == NULL)
{
return 1; /* In ``telnet.c'' it was ``return 0;''... -- Leon */
}
memcpy(addr, he->h_addr, he->h_length);
return 0; /* In ``telnet.c'' it was ``return 1;''... -- Leon */
}
int lookup_ip(char *host, struct in_addr *addr)
{ /* XXX: Does this support IPv6 IPs? -- Leon */
/* Use inet_addr for portability to Solaris */
/* Fuck Solaris -- Leon */
return (((*addr).s_addr = inet_addr(host)) == INADDR_NONE);
}
/* }}} */
/* {{{ DNS-related functions */
int resolve(char *host, struct in_addr *addr)
{
return (lookup_host(host,addr) && lookup_ip(host,addr));
}
void host2ip(char *s, char *host, int size)
{ /* TODO: Support IPv6 IPs, I guess. -- Leon */
struct in_addr addr;
u_char *p;
if (resolve(host, &addr))
{
StrCopy(s, host, size);
return;
}
p = (u_char *) &addr.s_addr;
snprintf(s, size, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
}
/* }}} */
/* {{{ net_*() */
/* {{{ net_set-type shit */
void net_set_socket_options(int sock)
{
int sw;
sw = 1;
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &sw, sizeof(sw));
sw = 1;
setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *) &sw, sizeof(sw));
sw = 0;
setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *) &sw, sizeof(sw));
}
void set_nonblocking(int sock)
{
int opts;
opts = fcntl(sock, F_GETFL);
if (opts < 0)
{
print_error("fcntl(F_GETFL)");
exit(EXIT_FAILURE);
}
opts = (opts | O_NONBLOCK);
if (fcntl(sock, F_SETFL, opts) < 0)
{
print_error("fcntl(F_SETFL)");
exit(EXIT_FAILURE);
}
}
/* }}} */
/* {{{ net_store*() */
netstore *net_store_new()
{
netstore *ns;
ns = xmalloc(sizeof(netstore));
memset(ns, 0, sizeof(netstore));
return ns;
}
void net_store_destroy(netstore *ns)
{
if (ns->ip6_hostent)
{
freeaddrinfo(ns->ip6_hostent);
}
free(ns);
}
/* }}} */
/* {{{ net_socket() */
int net_socket(int *sock, int type)
{
if ((*sock = socket(type, SOCK_STREAM, IPPROTO_TCP)) == -1)
{
return 1;
}
maxsock = max(*sock, maxsock);
net_set_socket_options(*sock);
set_nonblocking(*sock);
return 0;
}
/* }}} */
/* {{{ Resloving, connecting, binding functions */
int net_resolve(netstore *ns, char *hostname, unsigned short port)
{
struct addrinfo hints;
char portstring[MAX_HOSTNAME];
snprintf(portstring, MAX_HOSTNAME, "%d", port);
memset(&hints, 0, sizeof (struct addrinfo));
hints.ai_family = PF_UNSPEC; /* support IPv6 and IPv4 */
hints.ai_flags = AI_CANONNAME;
hints.ai_socktype = SOCK_STREAM;
return getaddrinfo(hostname, port ? portstring : NULL, &hints, &ns->ip6_hostent);
}
int net_connect(netstore *ns, int *sock, char *vhost)
{
struct addrinfo *res;
struct addrinfo *res0;
res0 = ns->ip6_hostent;
for (res = res0; res; res = res->ai_next)
{
switch (res->ai_family)
{
case AF_INET:
case AF_INET6:
if (net_socket(sock, res->ai_family))
{
return -1;
}
if (vhost && init_vhost(*sock, vhost))
{
return -1;
}
return connect(*sock, res->ai_addr, res->ai_addrlen);
}
}
return -1;
}
int net_bind(netstore *ns, int sock)
{
return bind(sock, ns->ip6_hostent->ai_addr, ns->ip6_hostent->ai_addrlen);
}
/* }}} */
/* }}} */
/* {{{ send_sock() */
void send_sock(int sock, const char *fmt, ...)
{
char buffer[BIGBUF];
int n;
va_list ap;
va_start(ap, fmt);
n = vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
send(sock, buffer, strlen(buffer), 0);
}
/* }}} */

500
muhstik/src/print.c Normal file
View File

@ -0,0 +1,500 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <time.h>
#include "../include/print.h"
#include "../include/string.h"
#include "../include/lists.h"
#include "../include/clone.h"
/* }}} */
/* {{{ Variables */
/* {{{ External Variables */
extern config_t conf;
extern int mute;
extern char *channel[];
extern char *broth[];
extern clone_t *cl[];
extern const char *strtype[];
extern char *op_nick;
extern int t0;
extern pthread_mutex_t mutex[];
/* }}} */
/* }}} */
/* {{{ print_*() */
inline void print_error(char *prefix)
{
print(1, 0, 0, "%s: %s", prefix, strerror(errno));
}
void print_irc(char *buffer, int color, int sock)
{
static char *color_codes[] = { "", "\026", "\0032", "\0037", "\0035", "\00314" };
send(sock, color_codes[color], strlen(color_codes[color]), 0);
send(sock, buffer, strlen(buffer), 0);
}
void print_privmsg(char *buffer, int color, int dest)
{
char tosend[BIGBUF];
dest = -dest-2;
snprintf(tosend, sizeof(tosend), "PRIVMSG %s :%s", op_nick, buffer);
print_irc(tosend, color, cl[dest]->sock);
}
void print_console(char *buffer, int ret, int color, int dest)
{
int len;
static char *color_term[] = { "\033[0;0m", "\033[0;35m", "\033[0;34m", "\033[0;1;1m", "\033[0;31m", "" };
if (!conf.nocolor)
{
len = strlen(buffer) - 1;
if (buffer[len] == '\n')
{
ret = 1;
}
if (ret)
{
buffer[len] = 0;
}
printf("%s", color_term[color]);
}
printf("%s", buffer);
if (!conf.nocolor)
{
printf("%s", color_term[0]);
if (ret)
{
printf("\n");
}
}
}
void print(int ret, int color, int dest, const char *fmt, ...)
{
char buffer[BIGBUF];
va_list ap;
if (dest == -1)
{
return;
}
va_start(ap, fmt);
vsnprintf(buffer, sizeof(buffer), fmt, ap);
va_end(ap);
if (ret)
{
StrCat(buffer, "\n", sizeof(buffer));
}
if (dest <= -2)
{
print_privmsg(buffer, color, dest);
return;
}
if (!mute)
{
pthread_mutex_lock(&mutex[1]);
print_console(buffer, ret, color, dest);
pthread_mutex_unlock(&mutex[1]);
}
}
void print_prefix(clone_t *clone, int color, int dest)
{
print(0, color, dest, "[%s;%s;%s] ", clone->nick, clone->proxy ? clone->proxy : "", clone->server);
}
void print_desc(int out, char *com, char *desc)
{
register int i;
print(0, 0, out, "%s", com);
for (i = strlen(com); i < LEN_TAB; ++i)
{
print(0, 0, out, " ");
}
print(1, 0, out, "%s", desc);
}
void print_line(int out)
{
register int i;
if (out >= 0)
{
for (i = 0; i < LEN_LINE; ++i)
{
print(0, 0, out, "-");
}
}
print(0, 0, out, "\n");
}
void print_motd(int out)
{
FILE *f;
char buffer[BIGBUF];
if ((f = fopen(conf.motd, "r")))
{
while (fgets(buffer, sizeof(buffer), f))
{
print(0, 0, out, "%s", buffer);
}
fclose(f);
}
}
/* }}} */
/* {{{ usage() */
void usage(int out)
{
char *(*p)[2];
static char *desc_general[][2] =
{
{ "help or ?", "print this help" },
{ STATUS, "print status {uptime,nicks,channels,users}" },
{ NULL, NULL }
};
static char *desc_actions[][2] =
{
{ "join", "JOIN or reJOIN a channel" },
{ "part", "PART a channel" },
{ "quit", "QUIT IRC and shut down the bot" },
{ "privmsg", "send a message or a CTCP to a nick or a channel" },
{ NICKS, "change all clone nicks" },
{ KICKBAN, "kickban a nick from a channel" },
{ ECHO, "make all the clones repeat what one nick says" },
{ TAKEOVER, "collide nicks on different servers" },
{ SELECT, "make one clone send something to IRC" },
{ NULL, NULL }
};
static char *desc_modes[][2] =
{
{ AGGRESS, "deop enemys actively and kick them on privmsg" },
{ PEACE, "don't automatically deop enemies" },
{ RANDOM, "use the wordlist to set the nicks" },
{ MUTE, "stop writing to stdout" },
{ NULL, NULL }
};
static char *desc_env[][2] =
{
{ NICKLIST, "change the active wordlist" },
{ CHANKEY, "set a key to be used when reJOINing a +k channel" },
{ LOAD, "load a clone dynamically" },
{ ADDPROT "/" RMPROT, "set/unset a protected nick" },
{ ADDJUPE "/" RMJUPE, "add/remove a nick to/from the jupe list" },
{ ADDOP "/" RMOP, "add/remove a pattern to/from the aop list" },
{ ADDSHIT "/" RMSHIT, "add/remove a pattern to/from the shitlist" },
{ ADDSCAN "/" RMSCAN, "set/unset a scan on JOIN" },
{ NULL, NULL }
};
print(1, 0, out, "Available commands:");
print_line(out);
for (p = desc_general; **p; ++p)
{
print_desc(out, (*p)[0], (*p)[1]);
}
print(1, 0, out, "\n- Actions:");
for (p = desc_actions; **p; ++p)
{
print_desc(out, (*p)[0], (*p)[1]);
}
print(1, 0, out, "%s, %s, %s, %s, %s: mass{op,KICK,KICKban,deop,unban}", MASSOP, MASSKICK, MASSKICKBAN, MASSDEOP, MASSUNBAN);
print(1, 0, out, "{KICK,MODE,TOPIC}: IRC protocol");
print(1, 0, out, "\n- Modes:");
for (p = desc_modes; **p; ++p)
{
print_desc(out, (*p)[0], (*p)[1]);
}
print(1, 0, out, "\n- Environment:");
for (p = desc_env; **p; ++p)
{
print_desc(out, (*p)[0], (*p)[1]);
}
print_line(out);
}
/* }}} */
/* {{{ print_uptime() */
void print_uptime(int out)
{
int uptime;
uptime = time(NULL) - t0;
print(1, 0, out, "muhstik v. %s, uptime: %d days, %02d:%02d:%02d", VERSION, uptime/86400, (uptime/3600)%24, (uptime/60)%60, uptime%60);
}
/* }}} */
/* {{{ nofclones() */
int nofclones()
{
register int i;
int k = 0;
clone_t **pcl;
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if (*pcl && (*pcl)->online)
{
++k;
}
}
for (i = 0; i < MAX_BROTHERS; ++i)
{
if (broth[i])
{
++k;
}
}
return k;
}
/* }}} */
/* {{{ is_empty_*() booleans */
int is_empty_str(char **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list)
{
return 0;
}
}
return 1;
}
int is_empty_scan(clone_t **list, int max)
{
register int i;
for (i = 0; i < max; ++i, ++list)
{
if (*list && (*list)->scan)
{
return 0;
}
}
return 1;
}
/* }}} */
/* {{{ print_nicks() */
void print_nicks(int out)
{
char nicks[BIGBUF];
char **p;
clone_t **pcl;
register int i;
if (!(i = nofclones()))
{
print(1, 0, out, "- no clones online");
return;
}
print(1, 0, out, "- %d clones online:", i);
memset(nicks, 0, sizeof(nicks));
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if (*pcl && (*pcl)->online)
{
StrCat(nicks, (*pcl)->nick, sizeof(nicks));
StrCat(nicks, " ", sizeof(nicks));
}
}
for (i = 0, p = broth; i < MAX_BROTHERS; ++i, ++p)
{
if (*p)
{
StrCat(nicks, *p, sizeof(nicks));
StrCat(nicks, " ", sizeof(nicks));
}
}
print(1, 0, out, "%s", nicks);
}
/* }}} */
/* {{{ nops() */
int nops(int chid)
{
register int i;
clone_t **pcl;
int k = 0;
for (i = 0, pcl = cl; i < MAX_CLONES; ++i, ++pcl)
{
if (is_op(*pcl, chid))
{
++k;
}
}
return k;
}
/* }}} */
/* {{{ print_*() */
void print_channels(int out)
{
char **p;
register int i;
print(1, 0, out, "- channels:");
for (i = 0, p = channel; i < MAX_CHANS; ++i, ++p)
{
if (*p)
{
print(1, 0, out, "%s (%d opped) ", *p, nops(i));
}
}
}
void print_scans(int out)
{
clone_t **p;
register int i;
print(1, 0, out, "- scans:");
for (i = 0, p = cl; i < MAX_CLONES; ++i, ++p)
{
if ((*p) && (*p)->online && (*p)->scan)
{
print(1, 0, out, "[%d] nick=%s, type=%s, port=%d, server=%s, saveto=%s",
i, (*p)->nick, strtype[(*p)->scan->type], (*p)->scan->proxy_port, (*p)->scan->server, (*p)->scan->save);
}
}
}
void print_aops(int out)
{
char **p;
register int i;
print(1, 0, out, "- auto op list:");
for (i = 0, p = conf.aop; i < MAX_AOPS; ++i, ++p)
{
if (*p)
{
print(1, 0, out, "[%d] %s", i, *p);
}
}
}
void print_jupes(int out)
{
char **p;
register int i;
print(1, 0, out, "- nick jupe list:");
for (i = 0, p = conf.jupe; i < MAX_JUPES; ++i, ++p)
{
if (*p)
{
print(1, 0, out, "[%d] %s", i, *p);
}
}
}
void print_prot(int out)
{
char **p;
register int i;
print(1, 0, out, "- protected nicks:");
for (i = 0, p = conf.prot; i < MAX_PROTS; ++i, ++p)
{
if (*p)
{
print(1, 0, out, "[%d] %s", i, *p);
}
}
}
void print_shit(int out)
{
char **p;
register int i;
print(1, 0, out, "- shitlist:");
for (i = 0, p = conf.shit; i < MAX_SHITS; ++i, ++p)
{
if (*p)
{
if (strchr(*p, ':'))
{
print(1, 0, out, "[%d] %s", i, *p);
}
else
{
print(1, 0, out, "[%d] %s :no reason", i, *p);
}
}
}
}
/* }}} */
/* {{{ status() */
void status(int out)
{
print_line(out);
print_uptime(out);
print_nicks(out);
if (!is_empty_str(channel, MAX_CHANS))
{
print_channels(out);
}
if (!is_empty_scan(cl, MAX_CLONES))
{
print_scans(out);
}
if (!is_empty_str(conf.aop, MAX_AOPS))
{
print_aops(out);
}
if (!is_empty_str(conf.jupe, MAX_JUPES))
{
print_jupes(out);
}
if (!is_empty_str(conf.prot, MAX_PROTS))
{
print_prot(out);
}
if (!is_empty_str(conf.shit, MAX_SHITS))
{
print_shit(out);
}
print_line(out);
}
/* }}} */

449
muhstik/src/proxy.c Normal file
View File

@ -0,0 +1,449 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Relevant Information:
* NOTE: Much of the following miles upon miles of utterly worthless blogging
* was taken from the BOPM source code.
*
* Cisco Routers: Cisco routers with a default password. Also pretty much
* anything else that will let you `telnet' to anywhere else
* on the Internet. These are (apparently) always on port 23.
*
* HTTP/1.1 {POST,CONNECT}:
*
* HTTP POST: The HTTP POST protocol used to often be dismissed when writing
* the access controls for proxies until a massive series of GNAA
* crapfloods.
* HTTP POST Offers only the opportunity to send a single block of
* data, but enough of them at once can still make for a
* devastating flood (see: `GNAA'.) Found on the same ports that
* HTTP CONNECT proxies inhabit.
* Note that if an ircd has "ping cookies" then clients from HTTP
* POST proxies cannot connect to the network anyway.
*
* HTTP CONNECT: A very common proxy protocol supported by widely known
* software such as Squid and Apache. The most common sort of
* insecure proxy and found on a multitude of weird ports too.
* Offers transparent two way TCP connections.
*
* [RFC2616] Hypertext Transfer Protocol -- HTTP/1.1 @ <http://tools.ietf.org/txt/rfc2616.txt>
* [RFC2617] HTTP Authentication: Basic and Digest Access Authentication @ <http://tools.ietf.org/txt/rfc2617.txt>
*
* SOCKS{4,5}: Well known proxy protocols, probably the second most common for
* insecure proxies, also offers transparent two way TCP
* connections. Largely confined to port 1080.
*
* SOCKS4:
* idk @ <http://socks.permeo.com/protocol/socks4.protocol>
* SOCKS: A protocol for TCP proxy across firewalls @ <http://www.digitalcybersoft.com/ProxyList/socks4.shtml>
* SOCKS 4A: A Simple Extension to SOCKS 4 Protocol @ <http://www.digitalcybersoft.com/ProxyList/socks4a.shtml>
*
* SOCKS5:
* [RFC1928] SOCKS Protocol Version 5 @ <http://tools.ietf.org/txt/rfc1928.txt>
* [RFC1929] Username/Password Authentication for SOCKS V5 @ <http://tools.ietf.org/txt/rfc1929.txt>
* [RFC1961] GSS-API Authentication Method for SOCKS Version 5 @ <http://tools.ietf.org/txt/rfc1961.txt>
* Challenge-Handshake Authentication Protocol for SOCKS V5 @ <http://www.tools.ietf.org/html/draft-ietf-aft-socks-chap>
*
* TOR:
* idk @ <http://www.sectoor.de/tor.php>
* Tor's extensions to the SOCKS protocol @ <https://git.torproject.org/checkout/tor/master/doc/spec/socks-extensions.txt>
* Design For A Tor DNS-based Exit List @ <https://git.torproject.org/checkout/tor/master/doc/contrib/torel-design.txt>
*
* Misc:
* [RFC3089] A SOCKS-based IPv6/IPv4 Gateway Mechanism @ <http://tools.ietf.org/txt/rfc3089.txt>
}}} */
/* {{{ Header includes */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "../include/proxy.h"
#include "../include/print.h"
#include "../include/net.h"
#include "../include/string.h"
#include "../include/print.h"
/* }}} */
/* {{{ Variables */
/* {{{ External variables */
extern config_t conf;
extern clone_t *cl[];
/* }}} */
/* {{{ Constants */
const char *strtype[] =
{
"SOCKS4",
"SOCKS5",
"proxy",
"cisco",
"vhost",
"direct"
};
/* }}} */
/* }}} */
/* {{{ connect_clone() */
int connect_clone(clone_t *clone, char *host, unsigned short port)
{
char *vhost = NULL;
netstore *ns = net_store_new();
if (clone->type == VHOST)
{
vhost = clone->proxy;
}
if (net_resolve(ns, host, port))
{
print(1, 4, 0, "%s: %s: nslookup failed", strtype[clone->type], host);
net_store_destroy(ns);
return 1;
}
if (net_connect(ns, &clone->sock, vhost))
{
if (errno != EINPROGRESS)
{
net_store_destroy(ns);
return 1;
}
}
clone->start = time(NULL);
net_store_destroy(ns);
return 0;
}
/* }}} */
/* {{{ init_*() */
int init_irc(clone_t *clone)
{
send_irc_nick(clone, clone->nick);
register_clone(clone);
return WAIT_IRC;
}
int init_vhost(int sock, char *vhost)
{
netstore *ns = net_store_new();
if (net_resolve(ns, vhost, 0))
{
print(1, 4, 0, "vhost: %s: nslookup failed", vhost);
net_store_destroy(ns);
return 1;
}
if (net_bind(ns, sock))
{
print(1, 0, 0, "vhost: bind: %s", strerror(errno));
net_store_destroy(ns);
return 1;
}
net_store_destroy(ns);
return 0;
}
/* {{{ SOCKS{4,5} */
/* {{{ CONNECT request byte order for SOCKS4
*
* +----+----+----+----+----+----+----+----+----+----+....+----+
* | VN | CD | DSTPORT | DSTIP | USERID |NULL|
* +----+----+----+----+----+----+----+----+----+----+....+----+
* # of bytes: 1 1 2 4 variable 1
*
*
* Responses:
* +----+----+----+----+----+----+----+----+
* | VN | CD | DSTPORT | DSTIP |
* +----+----+----+----+----+----+----+----+
* # of bytes: 1 1 2 4
*
* VN is the version of the reply code and should be 0. CD is the result
* code with one of the following values:
*
* 90: Request granted.
* 91: Request rejected or failed.
* 92: Request rejected because SOCKS server cannot connect to identd on the
* client.
* 93: Request rejected because the client program and identd report different
* user-IDs.
*
}}} */
int init_socks4(clone_t *clone)
{
char buffer[9];
struct in_addr addr;
unsigned short port;
port = htons(clone->port);
if (resolve(clone->host, &addr))
{
print(1, 4, 0, "%s: %s: nslookup failed", strtype[clone->type], clone->host);
clone->status = EXIT;
}
memcpy(&buffer[2], &port, 2);
memcpy(&buffer[4], &addr.s_addr, 4);
buffer[0] = 4;
buffer[1] = 1;
buffer[8] = 0;
send(clone->sock, buffer, 9, 0);
return WAIT_SOCKS4;
}
/* {{{ Send version authentication selection message to SOCKS5
*
* +----+----------+----------+
* |VER | NMETHODS | METHODS |
* +----+----------+----------+
* | 1 | 1 | 1 to 255 |
* +----+----------+----------+
*
* VER always contains 5, for SOCKSv5
* Method 0 is 'No authentication required'
*
*
*
* The SOCKS request is formed as follows:
*
* +----+-----+-------+------+----------+----------+
* |VER | CMD | RSV | ATYP | DST.ADDR | DST.PORT |
* +----+-----+-------+------+----------+----------+
* | 1 | 1 | X'00' | 1 | Variable | 2 |
* +----+-----+-------+------+----------+----------+
*
*
* o VER protocol version: X'05'
* o CMD
* o CONNECT X'01'
* o BIND X'02'
* o UDP ASSOCIATE X'03'
* o RSV RESERVED
* o ATYP address type of following address
* o IP V4 address: X'01'
* o DOMAINNAME: X'03'
* o IP V6 address: X'04'
* o DST.ADDR desired destination address
* o DST.PORT desired destination port in network octet
* order
*
}}} */
struct sock5_connect1
{
char version;
char nmethods;
char method;
};
int init_socks5(clone_t *clone)
{
struct sock5_connect1 sc1;
sc1.version = 5;
sc1.nmethods = 1;
sc1.method = 0;
send(clone->sock, (char *) &sc1, 3, 0);
return WAIT_SOCKS5_1;
}
int init_read_socks5(clone_t *clone)
{
unsigned short port;
unsigned char *sc2;
unsigned int addrlen;
unsigned int packetlen;
char buf[10];
if (recv(clone->sock, buf, 2, 0) < 2)
{
return EXIT;
}
if (buf[0] != 5 && buf[1] != 0)
{
return EXIT;
}
port = htons(clone->port);
addrlen = strlen(clone->host);
packetlen = 4 + 1 + addrlen + 2;
sc2 = xmalloc(packetlen);
sc2[0] = 5; /* version */
sc2[1] = 1; /* command */
sc2[2] = 0; /* reserved */
sc2[3] = 3; /* address type */
sc2[4] = (unsigned char) addrlen; /* hostname length */
memcpy(sc2 + 5, clone->host, addrlen);
memcpy(sc2 + 5 + addrlen, &port, sizeof(unsigned short));
send(clone->sock, sc2, packetlen, 0);
free(sc2);
return WAIT_SOCKS5_2;
}
/* }}} */
int init_proxy(clone_t *clone)
{
send_sock(clone->sock, "CONNECT %s:%d HTTP/1.0\r\n\r\n", clone->host, clone->port);
return WAIT_PROXY;
}
/* }}} */
/* {{{ readline() */
int readline(int s, char *buffer, size_t buffer_size)
{
char c;
unsigned int i = 0; /* ``unsigned'' is not needed, stops a warning when compiled with -Wextra */
do {
if (1 > read(s, &c, 1))
{
return 0;
}
if (i < (buffer_size - 1))
{
buffer[i++] = c;
}
} while (c != '\n');
buffer[i] = 0;
return i;
}
/* }}} */
/* {{{ Cisco-related, compile-time, constants */
#define CISCO_GREET "User Access Verification"
#define CISCO_PWD "cisco"
/* }}} */
/* {{{ read_*() */
/**
* read_cisco(): Cisco scanning
*
* Attempt to connect using `CISCO_PWD' as a password, then give command for
* telnet(1) to the scanip/scanport
*/
int read_cisco(clone_t *clone)
{
char buf[MEDBUF];
memset(buf, 0, sizeof(buf));
if (!readline(clone->sock, buf, MEDBUF))
{
return EXIT;
}
if (StrCmpPrefix(buf, CISCO_GREET))
{
return WAIT_CISCO;
}
send_sock(clone->sock, "%s\n", CISCO_PWD);
send_sock(clone->sock, "telnet %s %d\n", clone->host, clone->port);
return WAIT_IDENT;
}
int read_proxy(clone_t *clone)
{
char buf[MEDBUF];
memset(buf, 0, sizeof(buf));
if (!readline(clone->sock, buf, MEDBUF))
{
return EXIT;
}
if (memcmp(buf, "HTTP/", 5) || memcmp(buf + 9, "200", 3))
{
if (conf.debug)
{
print(0, 2, 0, "[%s;%s] PROXY: %s", clone->nick, clone->proxy, buf);
}
return EXIT;
}
return WAIT_IDENT;
}
int read_socks4(clone_t *clone)
{
char buffer[9];
if (recv(clone->sock, buffer, 8, 0) < 8)
{
return EXIT;
}
if (buffer[1] != 0x5A)
{
if (conf.debug)
{
print(1, 2, 0, "[%s;%s] SOCKS4: Connection refused", clone->nick, clone->proxy);
}
return EXIT;
}
if (conf.debug)
{
print(1, 2, 0, "[%s;%s] SOCKS4: Success", clone->nick, clone->proxy);
}
return WAIT_IDENT;
}
int read_socks5(clone_t *clone)
{
unsigned char buf[MEDBUF];
unsigned int packetlen;
/* consume all of the reply */
if (recv(clone->sock, buf, 4, 0) < 4)
{
if (conf.debug)
{
print(1, 2, 0, "[%s;%s] SOCKS5: Permission denied", clone->nick, clone->proxy);
}
return EXIT;
}
if (buf[0] != 5 && buf[1] != 0)
{
return EXIT;
}
if (buf[3] == 1)
{
if (recv(clone->sock, buf, 6, 0) != 6)
{
return EXIT;
}
}
else if (buf[3] == 4)
{
if (recv(clone->sock, buf, 18, 0) != 18)
{
return EXIT;
}
}
else if (buf[3] == 3)
{
if (recv(clone->sock, buf, 1, 0) != 1)
{
return EXIT;
}
packetlen = buf[0] + 2;
if (recv(clone->sock, buf, packetlen, 0) != packetlen)
{
return EXIT;
}
}
if (conf.debug)
{
print(1, 2, 0, "[%s;%s] SOCKS5: Success", clone->nick, clone->proxy);
}
return WAIT_IDENT;
}
/* }}} */

216
muhstik/src/string.c Normal file
View File

@ -0,0 +1,216 @@
/* Muhstik, Copyright (C) 2001-2002, Louis Bavoil <mulder@gmx.fr> */
/* 2009-2011, Leon Kaiser <literalka@gnaa.eu> */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU Library General Public License */
/* as published by the Free Software Foundation; either version 2 */
/* of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU Library General Public License for more details. */
/* {{{ Header includes */
#include <stdio.h>
#include <stdlib.h>
#include "../include/clone.h"
#include "../include/string.h"
#include "../include/print.h"
/* }}} */
/* {{{ External variables */
extern config_t conf;
/* }}} */
/* {{{ xmalloc() */
void *xmalloc(size_t size)
{
void *ret;
if (!(ret = malloc(size)))
{
print_error("malloc");
exit(EXIT_FAILURE);
}
return ret;
}
/* }}} */
/* {{{ Str*() */
char *StrDuplicate(char *src)
{
char *dest;
if (!src)
{
return NULL;
}
if (!(dest = strdup(src)))
{
print_error("malloc");
exit(EXIT_FAILURE);
}
return dest;
}
inline int StrCompare(char *s1, char *s2)
{
return (s1 && s2) ? strcasecmp(s1,s2) : 1;
}
inline int StrCmpPrefix(char *s1, char *s2)
{
return (s1 && s2) ? strncasecmp(s1,s2,strlen(s2)) : 1;
}
inline void StrFirstToken(char *s)
{
sscanf(s, "%s", s);
}
inline void StrCopy(char *s1, char *s2, size_t n)
{
strncpy(s1, s2, n);
s1[n-1] = 0;
}
inline void StrCat(char *s1, char *s2, size_t n)
{
if (strlen(s1) + strlen(s2) + 1 <= n)
{
strcat(s1, s2);
}
}
#ifdef NO_STRSEP
char *strsep(char **stringp, const char *delim)
{
char *res;
if (!stringp || !*stringp || !**stringp)
{
return NULL;
}
res = *stringp;
while (**stringp && !strchr(delim, **stringp))
{
(*stringp)++;
}
if (**stringp)
{
**stringp = '\0';
(*stringp)++;
}
return res;
}
#endif
int StrParam(char *parm, size_t size, char *s, int i)
{
register unsigned int k = 0; /* ``unsigned'' is not needed, stops a warning when compiled with -Wsign-compare */
memset(parm, 0, size);
while (i >= 0 && k < size)
{
if (*s == 0 || *s == '\n' || *s == '\r')
{
break;
}
if (*s == ' ')
{
--i;
}
else if (i == 0)
{
parm[k++] = *s;
}
++s;
}
return (i > 0 || parm[0] == 0) ? 1 : 0;
}
/* }}} */
/* {{{ Booleans */
int is_in(char *w, char *s)
{
char *parm;
while ((parm = strsep(&s, DELIM)))
{
if (!StrCompare(parm, w))
{
return 1;
}
}
return 0;
}
int is_nick(char *s)
{
return ((NULL == strchr(s, ',')) && (strlen(s) <= (unsigned) conf.nick_length)); /* ``unsigned'' is not needed, stops a warning when compiled with -Wsign-compare */
}
int is_pattern(char *s)
{
while ((*s != '\0') && (*s != '!') && (*s != '*'))
{
++s;
}
return (*s == '*') || (*s == '!');
}
/* }}} */
/* {{{ match_pattern() */
int match_pattern(char *pattern, char *string)
{
if (!string || !pattern)
{
return 0;
}
while (1)
{
if (!*string && !*pattern)
{
return 1;
}
if (!*string || !*pattern)
{
return 0;
}
if ((*string == *pattern) || (*string && *pattern == '?'))
{
++string;
++pattern;
}
else if (*pattern == '*')
{
if (*string == *(pattern + 1))
{
++pattern;
}
else if (*(pattern + 1) == *(string + 1))
{
++string;
++pattern;
}
else
{
++string;
}
}
else
{
return 0;
}
}
}
/* }}} */

100
muhstik/vhosts Normal file
View File

@ -0,0 +1,100 @@
2001:470:24:3f4:a310:3a08:2143:6005
2001:470:24:3f4:eab0:9f79:d2ee:b079
2001:470:24:3f4:49a3:bdfa:a9f4:3aec
2001:470:24:3f4:800c:1500:14c7:b150
2001:470:24:3f4:fbc4:7633:4e9c:931a
2001:470:24:3f4:2176:dcd9:d3e4:9cc4
2001:470:24:3f4:9da9:818e:9c0e:2622
2001:470:24:3f4:8ace:90b4:2a08:3cc
2001:470:24:3f4:3763:664e:8361:b9e1
2001:470:24:3f4:b293:4b5e:34d8:7309
2001:470:24:3f4:7c21:261:404:1e3b
2001:470:24:3f4:d1be:bc07:b010:38a
2001:470:24:3f4:abf4:3470:11d6:18fb
2001:470:24:3f4:accc:1f31:8e7d:d10f
2001:470:24:3f4:abdf:1447:533b:b667
2001:470:24:3f4:cc16:e61:69ee:3bf8
2001:470:24:3f4:85a5:c04b:1d79:33eb
2001:470:24:3f4:db4a:663f:9d76:301a
2001:470:24:3f4:4b5e:343f:cb5d:9c28
2001:470:24:3f4:76c0:4c44:6f60:4e15
2001:470:24:3f4:ed2:5f9b:673f:9902
2001:470:24:3f4:c8bf:ddbe:4359:fd4b
2001:470:24:3f4:5e64:bc8d:720:c029
2001:470:24:3f4:66d7:aad1:65a8:3de1
2001:470:24:3f4:2bc:c342:f3db:1067
2001:470:24:3f4:fc4f:34ae:56b4:567e
2001:470:24:3f4:c2fd:4b7d:83c0:d4f9
2001:470:24:3f4:cf9c:3275:fcf1:e08f
2001:470:24:3f4:a989:c5b0:1b5a:1fbe
2001:470:24:3f4:2f44:dc5a:b436:a3b8
2001:470:24:3f4:a62:cdf0:e6bf:2ab0
2001:470:24:3f4:bd8a:8b10:1531:78a3
2001:470:24:3f4:67bb:bda9:2ab9:9bc0
2001:470:24:3f4:744f:9fdd:141c:c9e1
2001:470:24:3f4:ab9a:eeea:6707:8bff
2001:470:24:3f4:a915:e6e4:37b3:5664
2001:470:24:3f4:5afe:3c4c:9bd3:6108
2001:470:24:3f4:2489:eed:29e8:d51b
2001:470:24:3f4:faf0:97b8:d5cf:20fa
2001:470:24:3f4:87a8:9523:df:4b1b
2001:470:24:3f4:98f5:25aa:5572:4c38
2001:470:24:3f4:7fdb:cef6:8562:b501
2001:470:24:3f4:e5a0:eefc:ed2b:d4b9
2001:470:24:3f4:183d:54a4:7548:2ccf
2001:470:24:3f4:b2d4:d8fa:5c92:844d
2001:470:24:3f4:5ed6:43f:d049:d16e
2001:470:24:3f4:a23d:4e6f:cd21:5a46
2001:470:24:3f4:64e3:4d04:c8cc:6de
2001:470:24:3f4:cd65:1ac:413a:1d23
2001:470:24:3f4:4cb0:8e12:f558:f25e
2001:470:24:3f4:2a0:fce7:27d7:fa82
2001:470:24:3f4:f0a1:6a50:8681:fb31
2001:470:24:3f4:3d03:42df:5ab8:84a4
2001:470:24:3f4:be7e:c7db:301d:7e49
2001:470:24:3f4:d85:963d:d076:f8b0
2001:470:24:3f4:d8d0:7b04:1039:a443
2001:470:24:3f4:4ee6:7414:c47c:673b
2001:470:24:3f4:e3ba:de9d:7fff:e871
2001:470:24:3f4:7d5a:11d8:6560:c540
2001:470:24:3f4:ec9d:566:dbee:a418
2001:470:24:3f4:3dc4:1cd9:65c1:90f2
2001:470:24:3f4:ceea:1cb0:2ceb:50c0
2001:470:24:3f4:cfc9:7254:ac0f:6ad4
2001:470:24:3f4:ca55:340f:68e3:fa6
2001:470:24:3f4:c382:ffa9:20ee:3c79
2001:470:24:3f4:2788:b56a:fc04:9ffa
2001:470:24:3f4:3428:c00d:d3f0:5597
2001:470:24:3f4:72d5:6bba:e7a:9173
2001:470:24:3f4:2596:ab0f:f776:f067
2001:470:24:3f4:37a1:c543:6320:2847
2001:470:24:3f4:c774:9a97:3ae7:344d
2001:470:24:3f4:68ff:b97:d524:bc0b
2001:470:24:3f4:f143:af8d:b49e:a860
2001:470:24:3f4:9977:8e67:3d0c:960a
2001:470:24:3f4:c62c:5c92:f11:f5ae
2001:470:24:3f4:42cd:42c6:934d:dec4
2001:470:24:3f4:660c:bfa8:54e3:99f9
2001:470:24:3f4:a2da:7b6e:94a0:69da
2001:470:24:3f4:a5f7:c8a3:8e81:78ca
2001:470:24:3f4:6cd5:f4ed:1f98:3b2c
2001:470:24:3f4:7215:5c60:7a2a:e54
2001:470:24:3f4:c118:95e0:1cb:abdc
2001:470:24:3f4:27f4:3680:3e5f:1f94
2001:470:24:3f4:90b2:7573:e053:8465
2001:470:24:3f4:3c9c:9285:f222:4ba5
2001:470:24:3f4:c5b9:6da:1526:910a
2001:470:24:3f4:3ed4:79e:1cb5:dd61
2001:470:24:3f4:405e:db3e:9028:8d01
2001:470:24:3f4:e4eb:f660:ea80:b711
2001:470:24:3f4:c3a6:cdd5:543f:35c7
2001:470:24:3f4:537:84dd:3651:46c5
2001:470:24:3f4:6c46:2c2f:5dfd:351a
2001:470:24:3f4:a028:5e25:7b35:4cef
2001:470:24:3f4:25a8:dd2a:176b:9958
2001:470:24:3f4:df2:2d68:f71:8a8a
2001:470:24:3f4:cd33:f635:f149:f178
2001:470:24:3f4:f694:9c0a:1d2c:63c
2001:470:24:3f4:80a2:50d6:5d2f:caf9
2001:470:24:3f4:14de:21f7:43f5:d920
2001:470:24:3f4:7b8e:90ca:d878:2cfc