=============================================================== Fearless Newsletter =============================================================== Issue: #1 July 21st, 2003 =============================================================== Contents: I. Introduction II. Fearless News III. Articles a) Trojans and R.A.Ts -=- AV detection - Server Strings ( Delphi ) b) Network Troubleshooting with the OSI model IV. Code and Scripts a) SiC's 'Leet mIRC' script (mIRC script) b) Text-based mass emailer for *nix (Unix shell script) c) A simple file-transfer example (C++) I. Introduction Well, its finally here.. This is the first edition of the Fearless Newsletter! This is a work in progress, and being the first issue, is bound to have inconsistencies as well as things we generally wish to change. Any comments, suggestions, or other related info can be sent to me at: merlion@areyoufearless.com! Please direct all rants to merlion@/dev/null. This first issue is a bit short - still testing the waters so to speak! First off, I'd like to thank everyone who has helped with the FreeGobo.com project. All your support is what helps get through this rough time. I'd like to give a special shout out to WackO for designing nearly ALL the merchandice available in the Free Gobo Store - good job mate! The latest news on Gobo: Gobo will be released in about two months time! This is due in part to a good behavior early release. He should this week be moved closer to home, and in about two months released. This is far better than we had anticipated at the mid to end of next year! All the letters of support were and still are very important to him. Thanks to all that have sent them, and any that still wish to may email the letters to me at merlion@areyoufearless.com. For all that were wondering, fsb has shaved off his sideburns. I know, its a big shock to all, but he assures us that it won't affect his charm at all.. lol For those that don't know fsb, well, he had sideburns.. ;P II. Fearless News Many of you are aware that we have joined the LCIRC network. Our old irc server was dodgy as hell, and only Gobo could access the administration aspects of it. SourceX from LCIRC was kind enough to buy us a shell for our own ircd, as long as we link to their network. So, want to talk to a Fearless coder? Exchange coding and hacking tips? Or just hang out with others in the community? Everyone is welcome! Fire up your favorite irc client and connect to: fearless.lcirc.net #fearless No spamming, flooding, or COLORS allowed!! :) -Shinyo >From Ghirai: Fearless Key Spy v2.0 is almost ready, in fact, it's currently being tested, so it won't be long now. The server size is 2.6 KB (packed), and it's probably the smallest keylogger with this set of features. I know i promised less than 2.5 KB, but i had to add some stuff to improve the stability. Same features as in v1.1, only you won't be able to configure the startup methods. I didn't see this feature as very important, so i removed it. Apart from FKS, i'm working on another asm project, that i'm sure all of you will love. More news on this soon. Remember to check out http://areyoufearless.com/ghirai/ and http://areyoufearless.com for updates. >From triforce: Well here is an update of what I have been doing project wise... I have been working on a FWB Web Downloader (WebFect) written in pure asm. I am basing it on my old webdownloader code, and am thinking about making the project opensource :) FeRAT 1.1 is also coming along but I need some more feedback from the Fearless community so check out the FeRAT forum to post ideas, or feel free to email me. Something that is also in the works is FeRAT v2.0 with a full api server using injection technology. It will have all the features, including the plugin system, that were in v1.0 and v1.1 of FeRAT. If you want more news on my projects then please visit my website (http://areyoufearless.com/triforce/, which when the dns servers are working will be http://triforce.areyoufearless.com.) Thats about it for me! Contact me: triforce@areyoufearless.com III. Articles IIIa) Trojans and R.A.Ts -=- AV detection - Server Strings ( Delphi ) Submitted by: Morning Wood ( morningwood@thepub.co.za ) Packing: ======== packing with UPX / asPack / FSG will not help much, as most good AV have PE analysis and detect and decompress these standard packers. Private type ( krew type custom packers ) are to be discouraged as well, unless you made it or can guarentee its private. Below is a sample from a "compressed" server... ( guess from what r.a.t ) USER SiCiglOO "blahsblah" "127.0.0.1" :suckmy NICK iGLOO[ http://www.fjun.com/sicmaggot j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! j0or a lamer! infect OWNED C:\iGLOO sabotage from=iGLOO-FE&fromemail=iGLOO-FE@Fun.editon port|version 2.01.0 iGLOO Fun Edition\ other strings from rats.. The UPX Team http://upx.sf.net 1996-2002 Markus F.X.J. Oberhumer ... yes from a compressed server strings such as these will get you detected faster than the newest Britney nipple bump pic hint: ===== Consider editing the following out completely, as 1. they serve no function 2. when AV find common strings with other known trojan type function strings, detection is highly suspect even if the file is not a trojan TWSocket (c) 1996-2002 Francois Piette V4.47 SOFTWARE\Borland\Delphi\RTL Software\Borland\Locales Software\Borland\Delphi\Locales Portions Copyright (c) 1983,99 Borland 2bits: ====== if we are dealing with uncompressed servers, simply editing these strings, repacking with a comercial or uncommon pe crypter will possibly make your server (more) undetected. TAKE OUT YOUR KIDDI STRINGS MMMMKAY I say: ===== before throwing in some "lookatmyrattiampimp" feature try for stable connection, solid file transfer and minimal strings. rember these 3 words in coding your next coollio r.a.t nuf said 1. stability 2. stability 3. stability greetz: ======= mah frienz who the fuck am i? ================== "im a sexy bitch" morning_wood@exploitlabs.com http://exploitlabs.com http://nothackers.org umm: ==== t'hnks to SiC for permissnz lettn me post his stuff from his OLD version and Merl for being the shitzziz he is. ***Note from Merl: You think I'm gonna take that line out?? ;D*** IIIb) Network Troubleshooting with the OSI model by fsb ( sacreman@cotse.net ) When troubleshooting networking it is always sensible to approach the problem from the perspective of the OSI model. The OSI, or Open System Interconnection, model defines a networking framework for implementing protocols in seven layers. The beauty of this model is the fact that you can individually troubleshoot every layer using simple methods. I suggest working from layer 1 upwards until you find the problem. Physical, Layer 1 : This layer conveys the bit stream - electrical impulse, light or radio signal -- through the network at the electrical and mechanical level. It provides the hardware means of sending and receiving data on a carrier, including defining cables, cards and physical aspects. Fast Ethernet, RS232, and ATM are protocols with physical layer components. I always start here to make sure that I don't waste time making things over complicated. If there are no lights on the network card, chances are that the cable is broken of there is a hardware failure on the network card itself. You can use cable testers to check cables, or use some common sense when swapping things round to isolate the cause of the problem. Making sure your operating system can see the hardware (and shows that it is functional) is also covered at this layer. Data Link, Layer 2 : At this layer, data packets are encoded and decoded into bits. It furnishes transmission protocol knowledge and management and handles errors in the physical layer, flow control and frame synchronization. The data link layer is divided into two sublayers: The Media Access Control (MAC) layer and the Logical Link Control (LLC) layer. The MAC sublayer controls how a computer on the network gains access to the data and permission to transmit it. The LLC layer controls frame synchronization, flow control and error checking. Most problems at this layer can be troubleshooted with the arp command (in windows anyway). MAC addresses are supposedly globally unique to a device, but some people like to play around which can cause problems (google for arp poisoning / spoofing). Using 'arp -a' will show you which MAC addresses are mapped to which IP addresses locally which is sometimes helpfull. You could also setup a network sniffer to look at the frames being sent across your hubs / switches. Network, Layer 3 : This layer provides switching and routing technologies, creating logical paths, known as virtual circuits, for transmitting data from node to node. Routing and forwarding are functions of this layer, as well as addressing, internetworking, error handling, congestion control and packet sequencing. This is a massive area to cover in a brief tutorial. It covers the routing protocols (rip1 and 2, ospf, igrp and a few others) as well as the routed protocols (most notably IP) . You can troubleshoot IP with icmp packets. Utilities like ping and tracert use icmp packets to get responses back from networked hosts.Packet sniffers can be setup to look at IP packets travelling across your hubs / switches in the same way as you would look at frame headers. The 'route print' command will show you your routing table in windows. Every other operating system will have commands to show the routing table (in IOS it would be 'sho ip route'). Common problems at this layer will be things like duplicate IP addresses on your network. Transport, Layer 4 : This layer provides transparent transfer of data between end systems, or hosts, and is responsible for end-to-end error recovery and flow control. It ensures complete data transfer. Most of the troubleshooting here would be done with a packet sniffer. TCP is used with IP as a means to ensure that the data within the packets is sent and received without any loss. If there is an error, packets are re-sent (it would be worth googling tcp packet header structure) with the correct sequence number so that no data is lost (it ensures complete data transfer). You can use packet sniffers to examine the tcp/udp packet headers to see what is happening at layer 4. Session, Layer 5 : This layer establishes, manages and terminates connections between applications. The session layer sets up, coordinates, and terminates conversations, exchanges, and dialogues between the applications at each end. It deals with session and connection coordination. The most likely thing you would be troubleshooting at this layer would be netbios over tcpip. Windows has some very useful utilities like nbtstat and the group of 'net' commands which will help you. Common mistakes are that people forget to install 'file and printer sharing' and 'client for microsoft networks' under Win9x operating systems and then wonder why they can't map drives or share folders. Other protocols like DNS, LDAP (this is used for most of the active directory replication), NFS, SQL, RPC and XWindows are also things that would be troubleshooted at this layer. Presentation, Layer 6 : This layer provides independence from differences in data representation (e.g., encryption) by translating from application to network format, and vice versa. The presentation layer works to transform data into the form that the application layer can accept. This layer formats and encrypts data to be sent across a network, providing freedom from compatibility problems. It is sometimes called the syntax layer. This layer looks at things like JPEG, MPEG, MIDI, QUICKTIME and other files of the same nature. Most of your troubleshooting will be with the applications that create them (at layer 7) but be aware that you can hex files to look at the structure and change them. Application, Layer 7 : This layer supports application and end-user processes. Communication partners are identified, quality of service is identified, user authentication and privacy are considered, and any constraints on data syntax are identified. Everything at this layer is application-specific. This layer provides application services for file transfers, e-mail, and other network software services. Telnet and FTP are applications that exist entirely in the application level. Tiered application architectures are part of this layer. If all of the other layers are working and have been tested, then this is usually just a matter of applying patches to software or reinstalling. Everyone probably has experience troubleshooting problems in windows. Telnet is an excellent tool for connecting to virtually any port to check to see if the above layers are functioning properly. This document was not written as a step by step guide to setting up a network, nor was it designed to give detailed instructions on how to troubleshoot each layer. There will be many utilities out there to help you find problems that aren't covered by the scope of this document. Also, google is a wonderful thing. I suggest you all use it. Please just look at this and keep it in your head as a model of how to breakdown networking into easily manageable layers so you can identify and fix problems in a more systematic way. If I have left anything major out please let me know. IV. Code and Scripts IVa) This is a mIRC script that has random fun commands, such as /die, /randfn, /leet , /lamer, and /bubbel Submitted by SiC ( tagge_70@hotmail.com ) ---------------------BEGIN SCRIPT-------------------------------------------- alias randFN { unset %nam3 %stre :tryagain set %nam3 $nick($chan,$rand(1,$nick($chan,0))) if (%nam3 == $me) { goto tryagain } if ($1 != $null) { set %nam3 $1 } set %tool $rand(0,8) set %action $rand(0,9) set %to $rand(0,8) set %stre * if (%action == 0) { set %stre %stre $+ $chr(32) $+ slaps } if (%action == 1) { set %stre %stre $+ $chr(32) $+ bash } if (%action == 2) { set %stre %stre $+ $chr(32) $+ bites } if (%action == 3) { set %stre %stre $+ $chr(32) $+ pokes } if (%action == 4) { set %stre %stre $+ $chr(32) $+ hits } if (%action == 5) { set %stre %stre $+ $chr(32) $+ smasch } if (%action == 6) { set %stre %stre $+ $chr(32) $+ tickles } if (%action == 7) { set %stre %stre $+ $chr(32) $+ scratch } if (%action == 8) { set %stre %stre $+ $chr(32) $+ h4xx } if (%action == 9) { set %stre %stre $+ $chr(32) $+ shots } set %stre %stre $+ $chr(32) $+ %nam3 to if (%to == 0) { set %stre %stre $+ $chr(32) $+ hell } if (%to == 1) { set %stre %stre $+ $chr(32) $+ death } if (%to == 2) { set %stre %stre $+ $chr(32) $+ japan } if (%to == 3) { set %stre %stre $+ $chr(32) $+ the moon } if (%to == 4) { set %stre %stre $+ $chr(32) $+ stoneage } if (%to == 5) { set %stre %stre $+ $chr(32) $+ france } if (%to == 6) { set %stre %stre $+ $chr(32) $+ swe } if (%to == 7) { set %stre %stre $+ $chr(32) $+ pre histroic age } if (%to == 8) { set %stre %stre $+ $chr(32) $+ n00b age } set %stre %stre $+ $chr(32) $+ with if (%tool == 0) { set %stre %stre $+ $chr(32) $+ a hammer } if (%tool == 1) { set %stre %stre $+ $chr(32) $+ the finger } if (%tool == 2) { set %stre %stre $+ $chr(32) $+ a pen } if (%tool == 3) { set %stre %stre $+ $chr(32) $+ a paper } if (%tool == 4) { set %stre %stre $+ $chr(32) $+ a monkey } if (%tool == 5) { set %stre %stre $+ $chr(32) $+ a keyboard } if (%tool == 6) { set %stre %stre $+ $chr(32) $+ mspaint } if (%tool == 7) { set %stre %stre $+ $chr(32) $+ a chair } if (%tool == 8) { set %stre %stre $+ $chr(32) $+ a elephant } set %stre %stre $+ $chr(32) $+ * msg $active %stre } alias die { unset %nam2 %n2 :tryagain set %nam2 $nick($chan,$rand(1,$nick($chan,0))) if (%nam2 == $me) { goto tryagain } set %n2 $rand(0,23) if (%n2 == 0) { msg $active *throw salt in %nam2 $+ 's eyes* } if (%n2 == 1) { msg $active *puts %nam2 on fire* } if (%n2 == 2) { msg $active *feed the sharks with %nam2 $+ * } if (%n2 == 3) { msg $active *pokes %nam2 to death with a dildo* } if (%n2 == 4) { msg $active *slaps %nam2 to death with a shoe* } if (%n2 == 5) { msg $active *drowns %nam2 in the toilet* } if (%n2 == 6) { msg $active *slaps %nam2 $+ 's face agains the wall* } if (%n2 == 7) { msg $active *cuts %nam2 $+ 's fingres off* } if (%n2 == 8) { msg $active *snap %nam2 $+ 's neck* } if (%n2 == 9) { msg $active *pushes %nam2 down the hill* } if (%n2 == 10) { msg $active *pushes %nam2 out from the plane* } if (%n2 == 11) { msg $active *lets the kitty eat %nam2 alive* } if (%n2 == 12) { msg $active *practice knife throwning at %nam2 $+ * } if (%n2 == 13) { msg $active *take %nam2 out for a bath in the lava* } if (%n2 == 14) { msg $active *pushes %nam2 so %nam2 fall on face and die* } if (%n2 == 15) { msg $active *breaks %nam2 $+ 's skull* } if (%n2 == 16) { msg $active *let FIDO the cow sit on %nam2 $+ * } if (%n2 == 17) { msg $active *hacksor %nam2 with mspaint* } if (%n2 == 18) { msg $active *runs over %nam2 with a car some times* } if (%n2 == 19) { msg $active *jump from roof and land on %nam2 $+ 's face* } if (%n2 == 20) { msg $active *skydive into %nam2 $+ * } if (%n2 == 21) { msg $active *slice %nam2 to death with a paper* } if (%n2 == 22) { msg $active *bash %nam2 to death with a paper* } if (%n2 == 23) { msg $active *stick %nam2 full of pens* } } alias fag { unset %name %nr :tryagain set %name $nick($chan,$rand(1,$nick($chan,0))) if (%name == $me) { goto tryagain } set %nr $rand(0,23) if (%nr == 0) { msg $active %name is homosexual } if (%nr == 1) { msg $active %name is fag } if (%nr == 2) { msg $active %name sucks my cock } if (%nr == 3) { msg $active %name like kids } if (%nr == 4) { msg $active %name are a pervert } if (%nr == 5) { msg $active %name should die } if (%nr == 6) { msg $active %name loves cock } if (%nr == 7) { msg $active %name have no balls } if (%nr == 8) { msg $active %name is a moron } if (%nr == 9) { msg $active %name is my lub } if (%nr == 10) { msg $active %name is hairy } if (%nr == 11) { msg $active %name have no brain } if (%nr == 12) { msg $active %name should be killed } if (%nr == 13) { msg $active %name dont know different between male and female } if (%nr == 14) { msg $active %name has 3 eyes } if (%nr == 15) { msg $active %name think hes a hackser } if (%nr == 16) { msg $active %name is a kiddie } if (%nr == 17) { msg $active %name cant manager mspaint } if (%nr == 18) { msg $active %name like to watch animalsex } if (%nr == 19) { msg $active %name loves me, i have to say, im not fag } if (%nr == 20) { msg $active %name got "fag" written on head } if (%nr == 21) { msg $active %name dont know how kids are made } if (%nr == 22) { msg $active %name wants head from bush } if (%nr == 23) { msg $active %name is a AI pig } } alias lamer { unset %aa %bb %a1 %a2 %a3 %ao %lineb %ab %ba %len2 %str2 %rnnd %randname set %aa 0 set %bb $rand(5,10) :lamer if (%aa <= %bb) { unset %lineb set %a1  set %a2  set %a3  set %ao  set %hink $rand(20,35) set %spade %hink set %ab 1 set %ba %spade :lam if (%ab <= %ba) { set %randname $rand(A,Z) $+ $rand(A,Z) $+ $rand(A,Z) $+ $rand(A,Z) set %rnd $rand(0,3) if (%rnd = 0) { set %lineb %lineb $+ %a1 $+ %randname } if (%rnd = 1) { set %lineb %lineb $+ %a2 $+ %randname } if (%rnd = 2) { set %lineb %lineb $+ %a3 $+ %randname } if (%rnd = 3) { set %lineb %lineb $+ %ao $+ $rand(0,99) $+ %randname } inc %ab goto lam } msg $active %lineb inc %aa goto lamer } } alias bubbel { unset %i1 %j1 %c1 %c2 %c3 %co %line2 %i2 %j2 %len2 %str2 %rnnd set %i1 0 set %j1 $rand(5,10) :bubmsg if (%i1 <= %j1) { unset %line2 set %c1  set %c2  set %c3  set %co  set %str2 $rand(20,35) set %len2 %str2 set %i2 1 set %j2 %len2 :bub if (%i2 <= %j2) { set %rnnd $rand(0,15) if (%rnnd = 0) { set %line2 %line2 $+ %c1 $+ bubbel } if (%rnnd = 1) { set %line2 %line2 $+ %c2 $+ bubbel } if (%rnnd = 2) { set %line2 %line2 $+ %c3 $+ bubbel } if (%rnnd = 3) { set %line2 %line2 $+ %co $+ $rand(0,99) $+ bubbel } if (%rnnd = 4) { set %line2 %line2 $+ %c1 $+ bobbel } if (%rnnd = 5) { set %line2 %line2 $+ %c1 $+ bobbel } if (%rnnd = 6) { set %line2 %line2 $+ %c1 $+ bobbel } if (%rnnd = 7) { set %line2 %line2 $+ %co $+ $rand(0,99) $+ bobbel } if (%rnnd = 8) { set %line2 %line2 $+ %c1 $+ babbel } if (%rnnd = 9) { set %line2 %line2 $+ %c2 $+ babbel } if (%rnnd = 10) { set %line2 %line2 $+ %c3 $+ babbel } if (%rnnd = 11) { set %line2 %line2 $+ %co $+ $rand(0,99) $+ babbel } if (%rnnd = 12) { set %line2 %line2 $+ %c1 $+ bibbel } if (%rnnd = 13) { set %line2 %line2 $+ %c1 $+ bibbel } if (%rnnd = 14) { set %line2 %line2 $+ %c1 $+ bibbel } if (%rnnd = 15) { set %line2 %line2 $+ %co $+ $rand(0,99) $+ bibbel } inc %i2 goto bub } msg $active %line2 inc %i1 goto bubmsg } } alias l33t { unset %i %j %len %str %chr %line set %str $lower($1-) set %len $len(%str) set %i 1 set %j %len :leet if (%i <= %j) { set %chr $mid(%str,%i,1) if (%chr == $chr(32)) { set %line %line $+ $chr(0160) inc %i goto leet } if (%chr == a) { set %line %line $+ 4 inc %i goto leet } if (%chr == b) { set %line %line $+ 8 inc %i goto leet } if (%chr == e) { set %line %line $+ 3 inc %i goto leet } if (%chr == i) { set %line %line $+ 1 inc %i goto leet } if (%chr == o) { set %line %line $+ 0 inc %i goto leet } if (%chr == r) { set %line %line $+ 2 inc %i goto leet } if (%chr == s) { set %line %line $+ 5 inc %i goto leet } if (%chr == t) { set %line %line $+ t inc %i goto leet } set %line %line $+ %chr inc %i goto leet } msg $active %line } on *:LOAD:{ Echo -a ----- Echo -a l33tz0r made by SiCz0r Echo -a greets to : jesus Echo -a ----- Echo -a use : Echo -a - Echo -a /LAMER Echo -a /BUBBEL Echo -a /FAG Echo -a /DIE Echo -a ----- Echo -a There is no gravity, its only the earth that sucks Echo -a ----- } on *:Unload:{ echo -a Worm activated, prepare to die. } -------------------------------- END SCRIPT------------------------------------------------------- IVb) The following is an older piece of code I wrote that is a text-based mass emailer with attachment support. I am re-releasing this here, as I have had many requests for it lately. This is a unix shell script, so you must chmod to 755 before running! -----------------------------BEGIN SCRIPT-------------------------------------------------------- #!/bin/sh # You must supply # your own email lists, as well as smtp server w/ relaying # Coded 02/02/02 by Merlion relayserv="$1" if [ $1 = "" ]; then echo "Usage is: filename " exit 1 fi # Replace the following address with your email LOGNAME=email@webpage.com # Replace the following with a path to a textfile containing # the text you wish to send in the message body TXTFILE=/home/loww/textfile # Replace the following with a path to the file to attach ATTFILE=/home/loww/Red2.jpg.pif # Replace the following with the subject of the message SUBJECT="New webpage!" # Replace the following with the path to a text file containing # the list of email adresses (newline seperated) EMAILLIST=/home/loww/email.txt for addy in `cat $EMAILLIST`; do MAILTO=$addy echo "From: $LOGNAME\nTo: $MAILTO\nSubject: $SUBJECT\n\ Mime-Version: 1.0\nContent-Type: text/plain\n" > /tmp/file cat $TXTFILE >> /tmp/file sendmail -t -oi < /tmp/file done rm -f /tmp/file exit 0 -----------------------END SCRIPT---------------------------- IVc) A quasi-simple example of transferring files from one computer to another. Submitted by akcom (bskak@hotmail.com) **Note: for anything other than microsoft visual C++, just include main.cpp and link ws2_32.lib** -------------begin main.cpp---------------------- /* defining WIN32_LEAN_AND_MEAN removes some less commonly used headers from windows.h */ #define WIN32_LEAN_AND_MEAN /* we're going to need this if we want to do anything w/ windows api calls! */ #include /* we need this to implement winsock 2 */ #include /* this if for user i/o */ #include DWORD resolve(char *szHost) { DWORD dwAddr = inet_addr(szHost); if (dwAddr != INADDR_NONE) { return dwAddr; } PHOSTENT pHost = gethostbyname(szHost); if (!pHost) { return INADDR_NONE; } return *(DWORD *)pHost->h_addr_list[0]; } int main() { WSAData wsa; WSAStartup(0x0202, &wsa); char cAddress[256]; int iPort; printf("enter ip to connect to:\r\n"); gets(cAddress); printf("enter the port:\r\n"); scanf("%d", &iPort); printf("enter the filename to retrieve:\r\n"); char cRemoteFile[261]; scanf("%s", cRemoteFile); char cSaveFile[261]; printf("enter the filename to save as:\r\n"); scanf("%s", cSaveFile); printf("connecting to %s:%d\r\n", cAddress, iPort); SOCKET s; sockaddr_in saddr; saddr.sin_family = AF_INET; saddr.sin_port = htons(iPort); saddr.sin_addr.S_un.S_addr = resolve(cAddress); if (saddr.sin_addr.S_un.S_addr == INADDR_NONE) { printf("unable to resolve host (%i)\r\n", WSAGetLastError()); return 1; } s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (s == INVALID_SOCKET) { printf("error on socket (%i)\r\n", WSAGetLastError()); return 2; } if (connect(s, (sockaddr *)&saddr, sizeof(saddr))) { printf("error on connect (%i)\r\n",WSAGetLastError()); closesocket(s); return 3; } /* ok, i should start explaining things first thing the client sends is the length of name of the file it wants the server to send +1 (for the null terminator). It then sends the name of the file it wants. After which the server sends the filesize. After this is done, the server prepares to send the file (creating the file ect) The client then sends a message signalling its ready to recieve the file. Then the transfer begins :) */ int iSize = strlen(cRemoteFile)+1; if (send(s, (char *)&iSize, sizeof(iSize), 0) != sizeof(iSize)) { printf("error sending filename length (%i)\r\n", WSAGetLastError()); closesocket(s); return 4; } if (send(s, cRemoteFile, iSize, 0) != iSize) { printf("error sending filename (%i)\r\n", WSAGetLastError()); closesocket(s); return 5; } DWORD dwFileSize; if (recv(s, (char *)&dwFileSize, sizeof(dwFileSize), 0) != sizeof(dwFileSize)) { printf("error recieving filesize (%i)\r\n", WSAGetLastError()); closesocket(s); return 6; } printf("file is %u bytes\r\n", dwFileSize); if (dwFileSize == -1) { printf("file does not exist, closing connection\r\n"); closesocket(s); return 7; } HANDLE hFile = CreateFile(cSaveFile, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, 0, 0); if (hFile == INVALID_HANDLE_VALUE) { printf("error creating file\r\n"); closesocket(s); return 8; } BYTE bReady = 0xF1; if (send(s, (char *)&bReady, sizeof(bReady), 0) != sizeof(bReady)) { printf("error sending ready byte (%i)\r\n", WSAGetLastError()); closesocket(s); return 9; } DWORD dwTotalRecv = 0; int iRecv; DWORD dwWritten; char cBuff[1024]; do { iRecv = recv(s, cBuff, sizeof(cBuff), 0); if (iRecv < 1) { printf("error recieving buffer (%i)\r\n", WSAGetLastError()); closesocket(s); return 10; } dwTotalRecv += iRecv; WriteFile(hFile, cBuff, iRecv, &dwWritten, 0); } while(dwTotalRecv != dwFileSize); CloseHandle(hFile); printf("transfer complete\r\n"); closesocket(s); WSACleanup(); return 0; } -------------------------------END main.cpp------------------------- Thats it for this issue. I hope you enjoyed it! Future submissions can be emailed to me at merlion@areyoufearless.com. Be safe everyone! -Merlion Notes: - Sorry for the blank newsletter sent out before this one. The PN module is confusing and I have a feeling we'll be using another method next time! =============================================================== * For more information, please visit our web site at http://areyoufearless.com. Please do not write to us using the address from which this email was sent. * If you do NOT wish to receive future event emails from areyoufearless.com visit the Subscriptions Services located at: http://areyoufearless.com/modules.php?op=modload&name=pnTresMailer&file=index. ===============================================================