home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / napalm / napalm-8.txt < prev    next >
Encoding:
Text File  |  2002-05-27  |  52.5 KB  |  1,390 lines

  1.  
  2.            /\  /^/_ _ __  __ _|^|_ __ ___
  3.           /  \/ / _` '_ \/ _` | | '_ ` _ \
  4.          / /\  / (_| |_)  (_| | | | | | | |
  5.         / /  \/ \__, .__/\__,_|_|_| |_| |_|
  6.                    |_|
  7.  
  8. .                                 .                      . ..n8: 2000.11.28
  9. ---------------------------------------------------------------------------
  10. all content copyright ⌐ 2000 by the individual authors. all rights reserved
  11. ---------------------------------------------------------------------------
  12.  
  13. # prtvtoc
  14. . . . .....................................................................
  15. 0x00  Editor's Comments
  16. 0x01  URLs
  17. 0x02  Subscriber Emails
  18. 0x03  Fun with Nortel M1231 Millennium Payphones
  19. 0x04  AT&T Assembly Syntax
  20. 0x05  IPSEC Bridging Under OpenBSD
  21. 0x06  Security Holes in Sun Cluster 2.x
  22. 0x07  Music Reviews
  23. 0x08  Credits
  24. ..................................................................... . . .
  25.  
  26. _________________________________
  27. ------------------------- - kynik
  28. [=] 0x00: Editor's Comments
  29.  
  30. Of course this issue is not as long as the previous one, but we've got a
  31. decent spread of articles this time, and no music review. See that section
  32. for details. For those of you writing articles for Napalm, please keep
  33. these guidelines in mind, not that these are problems, just for the simple
  34. fact that I need to write them down somewhere:
  35.  
  36. 1) Spell check
  37.  
  38. I do correct any spelling errors I find, and Ajax does the same on his
  39. second pass. We also correct grammar mistakes, but those are more
  40. acceptable, since there's many many free spell checkers out there. 
  41.  
  42. 2) Spaces after periods
  43.  
  44. One space after a period. I remove doubles by hand because I don't like
  45. it. Two spaces messes up the linebreaking and makes the whole issue
  46. longer.
  47.  
  48. 3) No tabs
  49.  
  50. Some people read these issues in their mail readers, and in various
  51. browsers. Don't use tabs to align columns and such. Use plain spaces, even
  52. if it seems wasteful to do so. I'd rather have the issues a little larger
  53. than have something look messed up on 10% of people's machines.
  54.  
  55. 4) Line length
  56.  
  57. Try not to make your lines longer than 75 characters or so. Some people
  58. read the issues in small windows. I personally hate having to stretch a
  59. window to read a file, or to have lines wrapping that only have a single
  60. word on them. You know what I mean.
  61.  
  62. 5) Two space indentation
  63.  
  64. This is just a personal preference of mine, so it overrides yours. And
  65. besides, it gives indentation without taking too much space. See #2.
  66.  
  67. 6) You can submit anonymously
  68.  
  69. If you have something cool you'd like to write, but you don't want to be
  70. recognized for whatever reason, we'll be more than happy to keep your
  71. email address unlisted or post the whole article anonymously.
  72.  
  73. If anybody has any questions, you know where to reach me:
  74. kynik@firest0rm.org
  75.  
  76. ____________________
  77. ------------ - kynik
  78. [=] 0x01: URLs
  79.  
  80. Free Software Developer's Community
  81. http://advogato.org/
  82.  
  83. Q&A about the Freedom of Information Act (FOIA)
  84. http://cpsr.org/cpsr/foia/foia_q&a.txt
  85.  
  86. Good listing of commonly-scanned ports
  87. http://www.sans.org/y2k/ports.htm
  88.  
  89. _________________________________
  90. ------------------------- - kynik
  91. [=] 0x02: Subscriber Emails
  92.  
  93. BlackOP007 <HELLSCREAM612@prodigy.net> writes:
  94.  
  95. hey there,
  96.     im a 17 year old in need of some answers.  i plan on attending
  97. college soon and would like to know what classes to take to help with my
  98. interest in becoming a network security analyst.  I am fascinated with
  99. the world of computers and security and would greatly appreciate any help
  100. you can give me.
  101.                                                         BlackOP007
  102.  
  103. [ I'd suggest anything that interests you, but that's a cop out, so here's
  104.   a list of what I'd recommend: Intro to Networking, (covers transport
  105.   protocols, hardware, media, routing, etc.) C/C++ programming, (gotta
  106.   write your personal utilities in something) Intro to Operating Systems,
  107.   maybe Artificial Intelligence and if they have a class for it, Data
  108.   Security. Not all schools will have the same selection as others (I was
  109.   fortunate enough to graduate from a larger state school, so I had a
  110.   broad range to choose from. It all depends on what interests you. Don't
  111.   take classes just to get a certain job. You will change your mind before
  112.   you're out of school. Take the classes that you like the most, and let
  113.   it go from there. {kynik} ]
  114.  
  115. ***********************************
  116.  
  117. Javier Llamas <jllamas@tab1.bal.com.mx> wrote:
  118.  
  119. Hi:
  120.  
  121.     I've checked out your articles for the 1st time and I think they're
  122. really cool. Thing is that I didn't understand as much as I would've
  123. liked to. So my question is... could you give me some sort of reference
  124. to get started on learning the VERY basics? I'm not intrested in
  125. cracking systems, but on fixing security holes (although I'm intrested
  126. on learning mostly anything... Thanks, bye
  127.  
  128. [ Unfortunately, many people get this same question every day. You need to
  129.   be more specific as to what you mean by the basics. Do you want to know
  130.   more about a particular operating system, or maybe about how the web
  131.   pages in your browser get to you? If you find something that you don't
  132.   understand, dig around (google.com is good) first to find what
  133.   information you can, then if you run into trouble understanding
  134.   something, feel free to ask a specific question. For good places to
  135.   start online, check out securityfocus.com or hackernews.com. {kynik} ]
  136.  
  137. __________________________________________________________________________
  138. -------------------------------------------------- - Flame0ut/PrussianSnow
  139. [=] 0x03: Fun with Nortel M1231 Millennium Payphones
  140.  
  141.              Toll Signalling And Collection Technology
  142.                 on Nortel M1231 Millennium Payphones
  143.                               ........
  144.                    And The Circumvention Thereof
  145.          (Or, "How We Didn't Pay For A Couple Of Phone Calls")
  146.  
  147.       A self-aggrandizing account by Flame0ut and PrussianSnow
  148.  
  149.               Published Around Late 2000 Or Something
  150.  
  151.                               ********
  152.  
  153. [ Standard disclaimer applies here: You use this for criminal activities,
  154.   and you will probably be punished. We won't bail you out, nor do we take
  155.   any responsibility for your use of this information. Knowledge is good.
  156.   All hail the giant pulsing brain. {kynik} ]
  157.  
  158.   One of the most common questions asked by young telephone enthusiasts
  159. in Canada is, "Can I red box Millennium phones?"
  160.  
  161. The answer, my friend, is no.
  162.  
  163. But some background first. The Millennium phone (model M1231) is an
  164. advanced payphone manufactured by Northern Telecom. A good deal of
  165. documentation concerning these phones is available on the Internet and
  166. through Northern Telecom (1-800-4-NORTEL), but to quickly list some of
  167. their "features":
  168.  
  169. - They have an LED screen displaying the current time, date, and a
  170.     programmable message.
  171. - They accept (in Canada) nickels, dimes, quarters and loonies, as well
  172.     as magnetic cards such as Bell Calling Cards and smartcards such as
  173.     Bell Quickchange Cards.
  174. - The dialing system is multi-layered and involves several firmware
  175.     systems; that is to say, the dialpad itself isn't responsible in any
  176.     way for making DTMF, but rather requesting another system to do so.
  177.     Note that if DTMF tones are played loudly into the microphone, they
  178.     will be displayed on the LED screen.
  179. - ACTS does NOT listen to these lines. Millennium Phones produce no tones
  180.     when coins are deposited - the line an M1231 sits on is free for
  181.     dialing out anywhere in the world with no blocking by an Automated
  182.     Coin Toll System. The only thing blocking you from dialing out on
  183.     these lines is the payphone itself, which does not actually pick up
  184.     the line and enable the microphone until it determines that a  
  185.     sufficient amount has been deposited. Note that the dialtone you hear
  186.     when you pick up the phone is internally generated, and the numbers
  187.     you "dial" are only actually dialled after the money is collected.
  188.     This, of course, is significant for our purposes.
  189. - When a long-distance number is dialed from the payphone, it displays a
  190.     message along the lines of "Getting Rates, please wait..." While
  191.     this message is displayed, a modem in the payphone is dialing an
  192.     internally-stored number to another modem, presumably at the
  193.     telephone company, from which it gets the rate for the number you
  194.     have dialed. In my area, this number is in the 416 area code, and it
  195.     can easily be gleaned by tapping the payphone line and recording then
  196.     decoding the DTMF. One could even, theoretically, record the exchange
  197.     between the modems and then play it into a modem that is in "silent
  198.     answer" mode to observe what happens during the connection, and
  199.     possibly figure out the protocol/commands used. Which, of course,
  200.     would be immoral and wrong.
  201.  
  202. But I digress.
  203.  
  204.   Millennium Payphones, and indeed, most payphones out there, store any
  205. coins you deposit in a temporary area until the line called is actually
  206. answered. As long as it is ringing or you get a busy signal or an error
  207. message, your money is not taken, and if you hang up before the line is
  208. actually answered you get your money back. It occurred one day to
  209. PrussianSnow and I to wonder how this happens - that is, how the payphone
  210. knows that the line was answered.
  211.  
  212.   We'd heard of payphones in which the toll signalling was done with
  213. tones generated by the CO - on a payphone line, the central office would
  214. generate tones telling the phone to return or take your coins depending
  215. on the circumstances; however, we've never directly observed this method.
  216.  
  217.   Fortuitously, PrussianSnow some time later discovered from Northern
  218. Telecom's website that one of the requirements for installing an M1231
  219. was "a phone line capable of current reversal". This is, of course, how
  220. the tolling is signalled.
  221.  
  222. Making a call from an M1231 works as such:
  223. - You dial a number, which is then stored internally.
  224. - The payphone waits for, collects, and verifies your money.
  225. - When a sufficient amount is deposited, the payphone goes off-hook and
  226.     dials the number you entered. At this point your money is in the
  227.     temporary area.
  228. - The microphone is enabled (which is also significant).
  229. - While the number you've called is ringing, the line current is positive
  230.   on ring and negative on tip, as is standard.
  231. - The line is answered. The CO detects this and flashes a voltage reversal
  232.   down the payphone line - for a moment, it is negative on ring and
  233.   positive on tip.
  234. - The payphone detects this flash, swallows your money, and enables the
  235.   dialpad. The voltage is normal (positive ring, negative tip) for the
  236.   rest of the call.
  237.  
  238.   There are a few alternatives - for instance, when a toll-free number is
  239. dialed, no voltage flash occurs so the dialpad must be enabled as soon as
  240. the number is dialed. Note that you can make tones while an 800 number is
  241. ringing, but not during a local one.
  242.  
  243.   The circumvention of this is obvious, and an example of the futility of
  244. placing the bulk of your security within reach of the end user (to be
  245. pedantic for a moment). You do not need to stop this voltage flash from
  246. happening, but rather, simply to stop the payphone from detecting it.
  247. Once this is done, the payphone will never receive a signal to swallow
  248. your money (or debit your Quickchange Card, as it were), and it will
  249. simply think that the line is ringing for the duration of your call. The
  250. CO will know better, but that is irrelevant.
  251.  
  252.   Four diodes, when hooked together so as to convert AC to DC, are
  253. collectively referred to as a full-wave rectifier (which can be purchased
  254. as a single component). Quite simply, a rectifier has 2 inputs and 2
  255. outputs, and its purpose is to force the polarity of the outputs to be
  256. constant no matter what the polarity of the inputs.
  257.  
  258.   Hence, when a rectifier is wired between the line and the payphone, the
  259. polarity can be forced to always be positive on ring and negative on tip.
  260.  
  261. [ I nominate that this be called a Flame Box, after its inventor, but
  262.   nobody probably cares what I think. (Or maybe a Snow Box?) {kynik} ]
  263.  
  264.   Right, enough theory. It's time to get For Educational Purposes Only on
  265. your ass, and talk about some application and installation.
  266.  
  267.   Our prototype of this fingle was a full-wave rectifier of an unknown
  268. rating (which happily proved to be enough - these things are generally
  269. used on house current AC so many handle up to 110V or 220V with 2 or 4
  270. amps, or more), wired up to a DPDT switch with 3 states -- unrectified,
  271. no flow at all (broken line -- no real reason for this one), and rectified
  272. polarity.
  273.  
  274.   It took PrussianSnow 40 minutes with his head stuck in the top of an
  275. M1231 booth off the side of a highway at midnight to get this thing wired
  276. up, but it worked the first time much to our orgasmic delight.
  277. (Educational purposes only)  It shouldn't really take that long to hook
  278. up, but this was the first one ever made so nyah. In our example, we'll
  279. be using just a rectifier with no DPDT.
  280.  
  281.   Installation is simple, and I'll list it in little steps with numbers
  282. beside so you don't accidentally do them out of order and hurt yourself.
  283.  
  284. Stuff to bring:
  285. - 1 pair of pliers
  286. - 1 full-wave rectifier
  287.  
  288. [ Flame box! Flame box! {kynik} ]
  289.  
  290. - 1 slot-head screwdriver
  291. - a couple of quarters or something
  292. - A flashlight couldn't hurt
  293. - And neither could some strippers
  294. - Some gloves would be nice, so you don't get any small shocks
  295. - And some biscuits, perhaps some Saltines or something of the like -
  296.     anything crunchy and delicious will do.
  297. - Alligator clips or crimpers would be nice.
  298.  
  299. 1. Locate the phone box for the payphone, or anywhere in the line where
  300.    you can easily cut it and splice in the rectifier. The phone box, of
  301.    course, is preferable. In a standard Millennium phonebooth, the
  302.    plastic "ceiling" is hinged on one side and latched in at the other
  303.    with 2 "tamper-proof" screws, which can be coerced out with a
  304.    slot-head screwdriver. You need only turn them about half a revolution.
  305. 2. Once the ceiling is swung down, you will have access to the phone box
  306.    as well as the 110-volt outlet which powers the lightbulb and the
  307.    payphone. Some booths have a power switch for the payphone. Don't
  308.    touch anything you don't have to, unless you want to. And you should
  309.    want to. You can make funny things happen. Note that the light takes
  310.    a long time to power up once unplugged and plugged back in.
  311. 3. Look at the phone box and eat a biscuit. Be contemplative. Note that
  312.    there are two main terminals - the one on the right has the ring  
  313.    wires; a red one going to the phone, and a blue one coming from the
  314.    line. The left terminal, tip, will have a green wire going to the
  315.    phone and a white wire going to the line. If these should vary,
  316.    just trust that the right terminal is ring, and positive. In some
  317.    phones it's actually the red and green that go to the phone line
  318.    rather than the phone - just figure out where the wires go, christ,
  319.    it's not all that hard. Geez. Whiner.
  320. 4. Loosen the nuts on the terminal bolts with the pliers you so
  321.    fortuitously brought along. Try not to let the green or red wires
  322.    come off the bolts, as that would be a pain you don't need. Pull out
  323.    the blue and white wires.
  324. 5. Run the blue wire (or whatever wire was on the right terminal) to an
  325.    AC input for the rectifier, and run the white wire (or whatever) to
  326.    the other AC input. You can attach them with gator clips,  
  327.    clothing-pins, crimpers or whatever. Maybe you could bring a
  328.    soldering iron and some solder, unplug the phone, plug your iron in,
  329.    wait a couple of minutes while it heats up, then solder the wires
  330.    together, unplug your iron, wait for it to cool down, put it away, and
  331.    plug the phone back in. That would be a story to tell.
  332. 6. Run the positive output to the right terminal and the negative output
  333.    to the left terminal. You can attach them by putting them behind the
  334.    nuts and tightening them again.
  335. 7. If the phone is still working, that's a good sign. Pick it up and
  336.    dial a number local to you. It will ask for a quarter. Deposit one.
  337. 8. If the number is dialed and the call goes through, you haven't broken
  338.    anything. If the number is dialed and you just hear silence, or the
  339.    LED screen declares "Phone Not In Service", check all your rectifier
  340.    connections and, as a last resort, assume that I've completely
  341.    forgotten whether ring is positive or negative and flip your output
  342.    polarity. Sorry.
  343. 9. Hold your breath. When the line is answered, the CO will send the
  344.    polarity-flip-flash. When it hits your rectifier, it will turn into
  345.    normal polarity and nothing will happen. So, when the line is
  346.    answered, the payphone won't take your money. At this point you may
  347.    jump around shouting gleefully.
  348. 10.Hang up the phone. Your money will fall into the coin-return slot.
  349.  
  350. Clink.
  351.  
  352. And that's that. The payphone is now, quite simply, free to use. Flip the
  353. ceiling back up and screw the latches back in.
  354.  
  355. Let's talk, now, about caveats.
  356.  
  357. - You need to have the money that the call would cost you or, for a long-
  358.   distance call, the money for the first minute (the timer will never
  359.   actually begin). A Quickchange card would be nice in this case.
  360.   You'll get it all back in the end, and the card will simply never get
  361.   debited.
  362. - Since the phone receives no polarity flash, and since the dialpad only
  363.   activates when it receives one, you may not use the dialpad while on
  364.   local or long-distance calls. Bring your tone generator if you want to
  365.   use a VMB or anything. Since toll-free calls produce no polarity flip,
  366.   the payphone must enable the dialpad as soon as it dials the number, as
  367.   mentioned before (pay attention!).
  368. - The M1231 may disconnect a call if it goes too long without being
  369.   answered to the payphone's knowledge. I have no example of this
  370.   happening, but it would only make sense. At any rate, you have at
  371.   LEAST 5 minutes. Probably more. Quite possibly this doesn't happen at
  372.   all, and I'm just a paranoid fuck.
  373. - This will likely work on any Millennium phone (M1231, M1232, and so on)
  374.   as well as any other payphone that uses this signalling.
  375. - Oddly enough, if you dial "0" from the phone, the operator will not be
  376.   able to hear you. We've yet to determine why this is, since there are
  377.   no other issues with microphone enabling.
  378. - Your rectifier may well get diked out when the phone company sees that
  379.   the payphone in question has made $0.00 in revenue for the last month
  380.   and a half. (Um, this seems to have been an understatement - note the
  381.   "update" at the bottom of this document!) For this reason, you may want
  382.   to make your rectifier togglable. Let's discuss this.
  383.  
  384.   To date, we've not determined a really good way to toggle the
  385. rectification. Ours had a DPDT switch but we have to pull down the
  386. ceiling to get at it, so gah. We've considered things such as a mercury
  387. switch sitting on the plastic ceiling so that you can toggle it by giving
  388. the ceiling a good thump (Fonzie-style), a relay in the circuit with part
  389. of the circuit going into the booth and the other going into a wire that
  390. we could hang through a corner of the ceiling, so that one could toggle
  391. the rectification by holding the wire against the side of the booth...
  392. we've even considered drilling a hole through the back of the booth and
  393. sticking a switch through it.
  394.  
  395. Whatever.
  396.  
  397. At any rate, I've gone on long enough and I'm tired. So, this is, of
  398. course, all for educational purposes only, and neither PrussianSnow nor I
  399. (Flame0ut) take any responsibility for anything this document may cause
  400. anyone to do.
  401.  
  402. Note that if NorTel would just make the microphone not activate until the
  403. voltage flash, this method would be moot.
  404.  
  405. It's a shame, really.
  406.  
  407. Enjoy!
  408.  
  409. ----
  410.  
  411. Update, about six months later:
  412. Yes, we wrote this document a long time ago and doddled about publishing
  413. it.
  414.  
  415. Some things have happened since which we feel are worth noting. Firstly:
  416. - Nortel no longer owns the M123X payphone line, it's been sold to a
  417.     company called Quortech who seems very twitchy about sending out
  418.     manuals (can't imagine why?)
  419. - Our prototype device and payphone have been removed. Both of them.
  420.     Completely.  Our proof-of-concept phone was loaded into a truck and
  421.     taken away for good. It took them five months, but the first ever
  422.     creation of this device is now in the hands of Bell Canada, godspeed
  423.     to it.
  424.  
  425. That's about all.
  426.  
  427. -------
  428. Questions?  Concerns?
  429. PrussianSnow and Flame0ut can be reached at the l0pht bbs at
  430. bbs.l0pht.com
  431. That is all.
  432. -------
  433.  
  434. [ Or I can relay messages to them if you send to napalm@firest0rm.org or
  435.   kynik@firest0rm.org {kynik} ]
  436.  
  437. _____________________________________
  438. ---------------------------- - Orbitz
  439. [=] 0x04: AT&T Assembly Syntax 
  440.  
  441.   If you are like me, you thought it would be an awesome idea to mix ASM
  442. in with your C/C++ programs, using gcc or DJGPP. There is only one
  443. catch: gcc uses AT&T style syntax. Anyways, you have two choices. One,
  444. you can give up on inline ASM in gcc and go download NASM. NASM compiles
  445. Intel syntax Assembly into an object file format which gcc can read and
  446. then you can compile it into the rest of your C code. Your other choice
  447. is to learn AT&T syntax. It isn't all that hard, really. This article
  448. will give you the limited knowledge you will need in order to do basic
  449. inline ASM. It should also be known, I suck at writing. I'm no fan of dry
  450. material, but it seems it is the only thing I am capable of - read at your
  451. own risk.
  452.  
  453. Prerequisites: 
  454. You need to know how to write at least some x86 Architecture Assembly.
  455. This is a must. You can get some x86 ASM help at  
  456. http://www.firest0rm.org/asm/
  457.  
  458. In The Beginning There Was The Syntax...:
  459. First, the syntax. Most of the operations are almost identical to their
  460. Intel counterparts. Lets imagine you want to put ax into bx. 
  461.  
  462. Intel style:
  463. mov bx, ax
  464.  
  465. AT&T Style:
  466. movw %ax, %bx
  467.  
  468.   You'll notice at first those %'s. A % designates the operand a register.
  469. A $ is put before immediates. That includes user defined variables as
  470. well as numbers. Also notice the order. AT&T goes opcode src, dest while
  471. Intel goes opcode dest, src. Last, notice the w hitched onto mov. The 'w'
  472. means 'word'. If I wanted to put eax into ebx it would look like:
  473.  
  474. movl %eax, %ebx
  475.  
  476. (The 'l' meaning 'long')
  477.  
  478. Now say you want to put the value 2 into ax.
  479.  
  480. Intel:
  481. mov ax, 2
  482.  
  483. AT&T:
  484. movw $2, %ax
  485.  
  486. Some misc. examples:
  487.  
  488. xorl %eax, %eax
  489. movw $myword, %ax
  490. movb $1, %ah
  491.  
  492. There are a few operations which are completely different. Here is a
  493. list:
  494.  
  495.  AT&T                   Intel
  496. ------------------------------------------------------------
  497.  movswl %ax, %ebx       movsx ebx, ax
  498.  cwtd                   cwd
  499.  cwtl                   cwde
  500.  cltd                   cdq
  501.  lret $X                ret far X
  502.  ljmp $S,$O             jump far S:O
  503.  lcall $S,$O            call far S:O
  504.  
  505.   The movswl line may need some further explanation. Intel has the movsx,
  506. and movzx operations while AT&T has movs and movz with a minor difference.
  507. In the example I am moving ax, a word, into ebx, a long. The size of the
  508. source and destination are on the operation. If I were moving al into
  509. ebx I would have done movsbl %al, %ebx.  
  510.  
  511. Operations such as rep stosd should be on SEPARATE lines, with stosd
  512. following the rep. That goes for all operations that have a prefix.
  513.  
  514. The Allmighty Memory References:
  515. Memory references are, of course very, important to assembly. AT&T and
  516. Intel's syntax are pretty different. Intel's resembles:
  517.  
  518. segment:[base + index * scale + disp]
  519.  
  520. and in AT&T:
  521.  
  522. segment:disp(base, index, scale)
  523.  
  524. Pretty weird, huh?
  525.  
  526. Some examples:
  527.  
  528.  AT&T                            Intel
  529. --------------------------------------------------------------------
  530.  movl 10(%edp), %ecx            mov ecx, [edp+10]
  531.  addl (%eax, %eax, 10), %ecx    add ecx, [eax + eax*10]
  532.  movb $10, %fs:(%eax)           mov fs:eax, 10
  533.  movl 4(,%eax,10), %eax         mov eax, [10*eax + 4]
  534.  
  535. Notice that 4 doesn't have a $ infront of it. In memory references you do 
  536. not use the $ before constants.
  537.  
  538.   With jumps you should use byte displacement most of the time. If a byte 
  539. displacement won't do, then a long is used, which is 32-bits. There are
  540. some opcodes which are only byte displacements.
  541.  
  542. The list: 
  543. jcxz
  544. jecxz
  545. loop
  546. loopz
  547. loope
  548. loopnz
  549. loopne
  550.  
  551. Here is an example of 'jcxz foo', from the gas (gnu assembler) manual:
  552.  
  553.     jcxz cx_zero
  554.     jmp cx_nonzero
  555. cx_zero: 
  556.     jmp foo
  557. cx_nonzero:
  558.  
  559. I Couldn't Think of a Clever Name For This Section:
  560.   I think that is all the AT&T Syntax you need to know for now; time for
  561. inline ASM in gcc. The function you'll use for inline ASM (well, sorta
  562. function. It doesn't quite follow standard C/C++ syntax, but whatever)
  563. looks like 
  564.  
  565. __asm__(asm statements : outputs : inputs : registers-modified);
  566.  
  567.   What does all this mean, you are asking yourself? Well, 'asm statements'
  568. is your code. 'outputs' is a constraint followed by a name in
  569. parentheses, separated by commas. Same for 'inputs'. 'registers-modified'
  570. are separated by commas as well. You do not have to use all of these,
  571. just as you need them. I'll get around to each one, but first...
  572.  
  573. Here is a simple inline ASM example for you:
  574.  
  575. __asm__("
  576.      pushl %eax\n
  577.      popl %eax"
  578.      );
  579.  
  580. [ For me? You shouldn't have! {kynik} ]
  581.  
  582.   This is fairly straight forward example. All it does is push eax to the
  583. stack, then pop it off again. Notice that the operations are surrounded
  584. by a pair of quotes. Also, the \n after each operation except the last
  585. where it is not needed. I found that in newer versions of gcc the \n was
  586. not necessary, however I recommend using it for style.
  587.  
  588. Yet another example, using the input field.
  589.  
  590. int yousuck = 1;
  591.  
  592. __asm__("
  593.      pushl %%eax\n
  594.      movl %0, %%eax\n
  595.      addl $50, %%eax\n
  596.      movl %%eax, %0\n
  597.      popl %%eax"
  598.      :
  599.      : "g" (yousuck)
  600.      );
  601.  
  602.   Pretty insane isn't it? Let me explain. First I'm making an integer
  603. 'yousuck', which equals 1. Then in my ASM I'm saving eax, so I don't
  604. lose whatever wonderful data was in there. Why does eax have a %% in
  605. front of it, and what is this %0, you ask? Well, since we are inputting a
  606. variable, gcc makes %0 through %however-many-you-input the input
  607. variables, then to easily distinguish between your input variables and
  608. registers, registers now take two %'s and the input variables take a %.
  609. Not too confusing if you think about it. Let's say you had 5 input
  610. variables, they would be %0, %1, %2, %3, and %4. Ok, so then I move the
  611. value of yousuck into eax, add 50 to it and move it back to yousuck. 
  612. Finally I pop eax, restoring its original value. 
  613.  
  614.   What is this "g" (yousuck) stuff? "g" is our constraint, and yousuck is
  615. the variable we are inputting. The "g" tells gcc that we don't care
  616. where it puts our variable yousuck, just as long as we have access to it.
  617. I'm told gcc might even optimize, if you are lucky. If you want to tell
  618. gcc where to put your variable, there are other constraints.  
  619.  
  620. The list:
  621. Constraint      Meaning
  622. -------------------------------------------------------
  623. r               load into any available register
  624. a               put it into eax
  625. b               put it into ebx
  626. c               put it into ecx
  627. d               put it into edx
  628. D               put it into edi
  629. S               put it into esi
  630.  
  631.   This list works for all the fields in the __asm__ function that take 
  632. constraints. Here is an example which uses three inputs.
  633.  
  634. int yousuck = 1, yousmell = 2, alot = 3;
  635.  
  636. __asm__("
  637.      pushl %%eax\n
  638.      movl %0, %%eax\n
  639.      addl %1, %%eax\n
  640.      addl %2, %%eax\n
  641.      movl %%eax, %0\n
  642.      popl %%eax"
  643.      :
  644.      : "g" (yousuck), "g" (yousmell), "g" (a lot)
  645.      );
  646.  
  647.   This simple example puts yousuck into eax, then adds the other two
  648. inputs to it then moves it back into yousuck. yousuck should now equal
  649. the sum of 1+2+3, which is 6.
  650.  
  651.   The next step is the output field of the __asm__ function. The truth
  652. is, I have yet to find much of a difference between the two fields, but
  653. whatever. You should know how to use it anyways. Here is an example
  654. using the output:
  655.  
  656. int yousuck = 1;
  657.  
  658. __asm__("
  659.      pushl %%eax\n
  660.      movl %0, %%eax\n
  661.      addl $1337, %%eax\n
  662.      movl %%eax, %0\n
  663.      popl %%eax"
  664.      : "=g" (yousuck)
  665.      );
  666.  
  667.   Basically, the only difference is you need to add a = in the constraint.
  668. In the tests I have done, I can use output basically exactly as input.
  669. If anyone has any idea what the difference is, please let me know. Next
  670. step, output and input at the same time. You are probably wondering how
  671. this will work. If output field uses the same numbering system (%0, %1,
  672. %2, etc) as input, won't they overwrite each other and all? No. It goes
  673. like this %0 through %however-many-in-the-output-field correspond to your
  674. variables for the output field, and %however-many-in-the-output-field+1 to
  675. %however-many-in-the-input-field + %however-many-in-the-output-field. I
  676. should chose shorter fake variable names, but oh well. Here is an
  677. example:
  678.  
  679. int yousuck = 0, yousmell = 2, youaredumb = 3;
  680.  
  681. __asm__("
  682.      pushl %%eax\n
  683.      movl %1, %%eax\n
  684.      addl %2, %%eax\n
  685.      movl %%eax, %0\n
  686.      popl %%eax"
  687.      : "=g" (yousuck)
  688.      : "g" (yousmell), "g" (youaredumb)
  689.      );
  690.  
  691. What's this do? It puts the value of yousmell into eax, adds the value of 
  692. youaredumb to it, then puts it into yousuck.  For further clarification, 
  693. %0 = yousuck, %1 = yousmell, %2 = youaredumb. Simple, right?
  694.  
  695.   The part of the __asm__ function we need to address is the
  696. registers-modified part. This is to handle whatever registers we are
  697. destroying. I rarely use this due to the fact I'm man enough to handle
  698. the pushing and popping of the registers I'm modifying on my own. If I
  699. weren't pushing and popping eax, my examples would look more like:
  700.  
  701. int yousuck = 1;
  702.  
  703. __asm__("
  704.      movl %0, %%eax\n
  705.      addl $1, %%eax\n
  706.      movl %%eax, %0"
  707.      :
  708.      : "g" (yousuck)
  709.      : "eax", "memory"
  710.      );
  711.  
  712.   As you can see, I put eax in as the register we modified. This mean that
  713. if necessary, gcc will take care of eax so we don't demolish it. The
  714. memory keyword after that is used since we are modifying the register.
  715. You should use that almost 100% of the time, unless you don't use the
  716. registers-modified field.
  717.  
  718.   One thing you should be made aware of is the __volatile__ addition to
  719. __asm__. With a normal __asm__ declaration, gcc will change, and optimize
  720. your inline ASM as it sees fit. You most likely do not want gcc to touch
  721. your code; this is what __volatile__ does. __volatile__ will tell gcc
  722. that this is your code and not to touch it. Here is an example:
  723.  
  724. int yousuck = 1;
  725.  
  726. __asm__ __volatile__("
  727.      pushl %%eax\n
  728.      movl %0, %%eax\n
  729.      addl $1, %%eax\n
  730.      movl %%eax, %0\n
  731.      popl %%eax"
  732.      :
  733.      : "g" (yousuck)
  734.      );
  735.  
  736. Now gcc won't modify your code in the slightest, which is a nice feature.  
  737. All that worked in a standard __asm__ function will work with __volatile__.  
  738.  
  739.   If you name locations in your code numbers, then in order for gcc to
  740. know if you are giving it a specific memory area, or a user defined
  741. location, you need to add an 'f' or 'b' postfix. The postfix indicates
  742. forward or backwards in the code. An example:
  743.  
  744. __asm__ __volatile__("
  745.      1:\n
  746.      jmp 2f\n
  747.      2:\n
  748.      jmp 1b"
  749.      );
  750.  
  751.   As you can see, when I jumped forward to the 2, I put an 'f' after and
  752. when I jumped back words to the 1, I put a 'b' in. As far as I have been
  753. able to see, you only run into this problem with numeric jump locations.
  754. If I were to name them Start, and End instead of 1 and 2, I would not
  755. need the f or b.
  756.  
  757.   That is all I have been able to think of over the past few weeks. I
  758. would like to thank www.linuxassembly.org for their awesome tutorials,
  759. and The QuickASM Programming Guide (linked off the linuxassembly page).
  760. These sites taught me how to do AT&T syntax and inline. gcc -S myfile.c
  761. was also a big help.
  762.  
  763.   Questions and nice comments should be send to orbitz@firest0rm.org
  764. Bitches should be directed towards IDon'tCare@firest0rm.org
  765.  
  766. Orbitz
  767.  
  768. [ Orbitz, I've set up the alias IDon'tCare to point to you, if that's okay
  769.   with you ;) {kynik} ]
  770.  
  771. _____________________________________________
  772. ------------------------------------ - _azure
  773. [=] 0x05: IPSEC Bridging Under OpenBSD
  774.  
  775. IPSEC Bridging Under OpenBSD (or: Plugging Holes With Your Fingers)  
  776.  
  777. Intro
  778.  
  779.   In a previous article I outlined one method for integrating Windows  
  780. networks into a secure VPN with IPSEC and Samba. This time around I'm
  781. going to demonstrate an alternative method of achieving what is  
  782. essentially the same functionality in a completely different way.  
  783.  
  784.   Your mileage may have varied in trying to juggle separate subnets,
  785. identical/different Domains, and NetBIOS integrity across your VPN.
  786. In this instance the connection we'll create is not tied to any
  787. particular proprietary protocols or services; yet may actually end
  788. up serving your purposes in a more ideal fashion. It is also a much
  789. simpler method of joining remote Local Area Networks that may not need 
  790. to be functionally separated at all.  
  791.         
  792. Cutting directly to the chase:
  793.  
  794.   IPSEC bridging is essentially the same as the traditional interface
  795. bridging you are already familiar with. One minor exception is that
  796. the OSI layer-2 information is propagated across the VPN instead of
  797. merely across your physical hardware. Generally however: As above, 
  798. so below.
  799.  
  800. For our purposes in this example we will bridge two remote LANs; each with
  801. physically separate internal and external interfaces.
  802.  
  803.  
  804.   [Net-1]----> [bridge1/IPF] <--------> [bridge2/IPF] <----[Net-2]
  805.  
  806.         
  807.   An interface on Net-1 is bridged to an interface on Net-2. Ethernet
  808.   frames are encapsulated and sent across the VPN where they are stripped
  809.   out and placed back on the wire by the bridging code itself.
  810.        
  811.   The OpenBSD boxes will be serving only as hardware bridging devices - we
  812. will not concern ourselves with how users gain access to the Internet in
  813. general. It is not even necessary for the client machines to know the
  814. bridges exist (or to have normal Internet connectivity at all, for that
  815. matter). Unlike in the previous article, this time OpenBSD is *completely*
  816. transparent to endusers.
  817.  
  818.  
  819. .Configuring OpenBSD's Implementation
  820.  
  821.   This will differ depending on your particular installation of OpenBSD.
  822. The syntax for ipsecadm(8) has changed with every release since its
  823. integration into the base operating system. The examples included in this
  824. document will assume OpenBSD 2.8-RELEASE. Leaving aside the politics of
  825. our multi-party system (*BSD, Linux, etc.), OpenBSD is a robust player in
  826. the UNIX game; and also includes all the tools we need in its default
  827. install.
  828.  
  829.  
  830. ..Customizing and Patching the Kernel for Load
  831.  
  832. However, customizing the kernel to fit specific hardware is always a good
  833. idea. It cuts down the size of the file that is loaded into memory; thus
  834. increasing system performance. There are also changes you can make to
  835. maximize networking performance. Some additional options you'll want to
  836. include in your config before recompiling are:
  837.  
  838. option IPFORWARDING
  839. option IPFILTER
  840. option IPFILTER_LOG
  841. option NMBCLUSTERS = 8192
  842.  
  843.  
  844. For additional information on tuning, see the OpenBSD performance tuning
  845. FAQ:
  846.  
  847. [ http://www.openbsd.org/faq/faq11.html#11.1 ]
  848.  
  849.  
  850. Patches should also be applied accordingly. At the time of this writing,
  851. no patches have been issued for OpenBSD 2.8. Information on versions
  852. prior to 2.8 is available at:
  853.  
  854. [ http://www.openbsd.org/errata.html ]
  855.  
  856. [ And you don't want to be running 2.7 or previous, a lot of IPsec bugs
  857.   have been fixed in 2.8.  Besides which, I'm pretty sure some of the
  858.   syntax to brconfig and ipsecadm changed, so this article might not
  859.   work at all. {ajax} ]
  860.  
  861. You will need to edit /etc/rc.conf to activate IPFILTER and IPNAT at boot
  862. time.
  863.  
  864. You will also need to have net.inet.ip.forwarding=1 in your  
  865. /etc/sysctl.conf file.
  866.  
  867. Reboot and rinse.
  868.  
  869.  
  870. ..IFCONFIG, BRCONFIG and IPSECADM
  871.  
  872.   An IPSEC bridge is configured using standard command line tools. An ENC
  873. interface is added to the bridge with brconfig(8), and associated with
  874. existing SAs using ifconfig(8). ipsecadm is used to create the relevant
  875. IPSEC flows. Finally, all interfaces are brought up and layer-2
  876. information begins to travel across the VPN.
  877.  
  878. An example configuration is provided below.
  879.  
  880.  
  881. First of all we'll need to generate keys for the IPSEC transactions:
  882.  
  883. # openssl rand 20 | hexdump -e '20/1 "%02x"' > KEYFILE_LOCATION
  884. # openssl rand 20 | hexdump -e '20/1 "%02x"' > AUTHKEYFILE_LOCATION
  885.  
  886.  
  887. Then we construct a two-node IPSEC bridge as follows:
  888.  
  889.         
  890. On both OpenBSD boxes:
  891.  
  892. # brconfig bridge0 add ENC_INTERFACE PRIVATE_INTERFACE
  893.  
  894. # brconfig bridge0 blocknonip   (to block non-ip traffic)
  895.         
  896. # brconfig bridge0 link1         (to block ip multicasts)
  897.  
  898. # ipsecadm new esp -spi SPI1 -dst BRIDGE2_PUBLIC_IP -src \
  899.   BRIDGE1_PUBLIC_IP -enc blf -auth sha1 -keyfile \
  900.   KEYFILE_LOCATION -authkeyfile AUTHKEYFILE_LOCATION
  901.  
  902. # ipsecadm new esp -spi SPI2 -dst BRIDGE1_PUBLIC_IP -src \
  903.   BRIDGE2_PUBLIC_IP -enc blf -auth sha1 -keyfile \
  904.   KEYFILE_LOCATION -authkeyfile AUTHKEYFILE_LOCATION
  905.  
  906.  
  907. On BRIDGE1:
  908.  
  909. # ipsecadm flow -dst BRIDGE2_PUBLIC_IP -in -transport etherip \
  910.   -require -addr BRIDGE1_PUBLIC_IP 255.255.255.255 \
  911.   BRIDGE2_PUBLIC_IP 255.255.255.255 
  912.  
  913. # ifconfig ENC_INTERFACE dstsa BRIDGE2_PUBLIC_IP/SPI1/esp
  914.  
  915. # ifconfig ENC_INTERFACE srcsa BRIDGE1_PUBLIC_IP/SPI2/esp
  916.  
  917. # ifconfig PRIVATE_INTERFACE up         (if not already up)
  918.  
  919. # ifconfig ENC_INTERFACE up
  920.  
  921. # brconfig bridge0 up
  922.  
  923.  
  924. On BRIDGE2:
  925.  
  926. # ipsecadm flow -dst BRIDGE1_PUBLIC_IP -in -transport etherip \
  927.   -require -addr BRIDGE2_PUBLIC_IP 255.255.255.255 \
  928.   BRIDGE1_PUBLIC_IP 255.255.255.255
  929.  
  930. # ifconfig ENC_INTERFACE dstsa BRIDGE1_PUBLIC_IP/SPI2/esp
  931.  
  932. # ifconfig ENC_INTERFACE srcsa BRIDGE2_PUBLIC_IP/SPI1/esp
  933.  
  934. # ifconfig PRIVATE_INTERFACE up         (if not already up)
  935.  
  936. # ifconfig ENC_INTERFACE up
  937.         
  938. # brconfig bridge0 up
  939.  
  940.  
  941. It is not strictly necessary for INTERNAL_INTERFACE to have an IP address
  942. on either side of the VPN. 
  943.  
  944.  
  945. ..Viewing Stats and Turning the Bridge Off
  946.  
  947. To view a table of MAC addresses functioning on your bridge at any time,
  948. use:
  949.  
  950.  
  951. # brconfig -a
  952.  
  953.  
  954. which produces results similar to:
  955.  
  956.   bridge0: flags=0<>
  957.           Interfaces:
  958.           Addresses (max cache: 100, timeout: 240):
  959.   bridge1: flags=0<>
  960.           Interfaces:
  961.           Addresses (max cache: 100, timeout: 240):
  962.  
  963.  
  964. To disable the bridge and remove the IPSEC SAs, use:
  965.  
  966. # brconfig bridge0 delete ENC_INTERFACE
  967.  
  968. # brconfig bridge0 delete INTERNAL_INTERFACE
  969.  
  970. # brconfig bridge0 down
  971.  
  972. # ifconfig ENC_INTERFACE down
  973.         
  974. # ifconfig ENC_INTERFACE clearsa 0.0.0.0/0/0
  975.  
  976.  
  977. This will return your system to normal (pre-bridge) status.
  978.         
  979.  
  980. ...Too Lazy To Type 
  981.  
  982. I have again written a short perl utility to construct ifconfig(8), 
  983. brconfig(8) and ipsecadm(8) rules against user-supplied network 
  984. information. ipsec_bridge_2.8.pl can be retrieved from:
  985.  
  986.  
  987. [ http://azure.gh0st.net/perl/ipsec_bridge_2.8.pl ]
  988.  
  989.  
  990. [ Or it can be grabbed from napalm's main page, under addenda. {kynik} ]
  991.  
  992.  
  993.   You can run the output of this utility on both ends of your would-be VPN
  994. to initialize an IPSEC bridge between private interfaces (as is described
  995. in detail above).
  996.  
  997.   Specific information on the mechanics of IPSEC and bridging themselves  
  998. are beyond the scope of this article, but can be gleaned from relevant  
  999. man pages and freely available reference elsewhere on the Internet.
  1000.  
  1001.  
  1002. ..Filtering For Bandwidth's Sake
  1003.  
  1004.   It all sounds great until you realize that broadcast information on your
  1005. LAN is also going to be transmitted across your limited bandwidth VPN
  1006. connection. With Windows-based machines on your network this can quickly
  1007. spell disaster. Fortunately, the ancient ones have sprinkled the golden
  1008. dust of their approval upon our efforts: IPF.
  1009.  
  1010.  
  1011. ...IPF
  1012.  
  1013.   Stateful packet filtering with IPF can protect the bridge from external
  1014. 'influence' while keeping the frames passing across the VPN from
  1015. overwhelming both upstream connections. In this example we will filter
  1016. broadcasts as they come in on the INTERNAL_INTERFACE before they are
  1017. handed off to the bridge. Keep in mind that a separate filtering rule
  1018. will have to be added for each network that touches the bridging
  1019. interface.
  1020.  
  1021.   Other possibilities include filtering on the bridge interface itself.
  1022. (See brconfig(8) for details on filtering at the bridge level.)
  1023.  
  1024.  
  1025. Included below is a sample template for configuring IPF:
  1026.         
  1027.  
  1028.   xxx.xxx.xxx = relevant portion of the external IP on BRIDGE1
  1029.   yyy.yyy.yyy = relevant portion of the internal IP on BRIDGE1
  1030.   aaa.aaa.aaa = relevant portion of the external IP on BRIDGE2
  1031.   bbb.bbb.bbb = relevant portion of the internal IP on BRIDGE2
  1032.  
  1033.         
  1034. on BRIDGE1:
  1035.  
  1036. # /etc/ipf.rules
  1037. #
  1038.  
  1039. # block everything by default unless another rule says otherwise
  1040. block in log level local0.info on EXTERNAL_INTERFACE
  1041.  
  1042. # block spoofed traffic on external interfaces
  1043. block in quick on EXTERNAL_INTERFACE from 127.0.0.0/8 to any
  1044. block in quick on EXTERNAL_INTERFACE from 10.0.0.0/8 to any
  1045. block in quick on EXTERNAL_INTERFACE from 172.16.0.0/12 to any
  1046. block in quick on EXTERNAL_INTERFACE from 192.168.0.0/24 to any
  1047. block in quick on EXTERNAL_INTERFACE from any to xxx.xxx.xxx.0/32
  1048. block in quick on EXTERNAL_INTERFACE from any to xxx.xxx.xxx.255/32
  1049.         
  1050. # block broadcast traffic from the internal network
  1051. block in quick on INTERNAL_INTERFACE from any to yyy.yyy.yyy.0/32
  1052. block in quick on INTERNAL_INTERFACE from any to yyy.yyy.yyy.255/32
  1053.  
  1054. # pass traffic out from EXTERNAL_INTERFACE and from INTERNAL_NETWORK
  1055. pass out quick on EXTERNAL_INTERFACE proto tcp/udp from \
  1056. BRIDGE1_EXTERNAL_IP/32 to any keep state
  1057. pass out quick on EXTERNAL_INTERFACE proto icmp from \
  1058. BRIDGE1_EXTERNAL_IP/32 to any keep state
  1059. pass out quick on EXTERNAL_INTERFACE proto tcp/udp from \
  1060. BRIDGE1_INTERNAL_NETWORK/24 to any keep state
  1061.  
  1062. # pass IPSEC traffic for bridge0 and enc1
  1063. pass in quick proto esp from BRIDGE2_EXTERNAL_IP/32 to \
  1064. BRIDGE1_EXTERNAL_IP/32
  1065. pass out quick proto esp from BRIDGE1_EXTERNAL_IP/32 to \
  1066. BRIDGE2_EXTERNAL_IP/32
  1067. pass in quick on enc1 from BRIDGE2_INTERNAL_NETWORK/24 to \
  1068. BRIDGE1_INTERNAL_NETWORK/24
  1069.  
  1070.         
  1071. on BRIDGE2:
  1072.  
  1073. # /etc/ipf.rules
  1074. #
  1075. # block everything by default unless another rule says otherwise
  1076. block in log level local0.info on EXTERNAL_INTERFACE
  1077.  
  1078. # block spoofed traffic on external interfaces
  1079. block in quick on EXTERNAL_INTERFACE from 127.0.0.0/8 to any
  1080. block in quick on EXTERNAL_INTERFACE from 10.0.0.0/8 to any
  1081. block in quick on EXTERNAL_INTERFACE from 172.16.0.0/12 to any
  1082. block in quick on EXTERNAL_INTERFACE from 192.168.0.0/24 to any
  1083. block in quick on EXTERNAL_INTERFACE from any to aaa.aaa.aaa.0/32
  1084. block in quick on EXTERNAL_INTERFACE from any to aaa.aaa.aaa.255/32
  1085.        
  1086. # block broadcast traffic from the internal network
  1087. block in quick on INTERNAL_INTERFACE from any to bbb.bbb.bbb.0/32
  1088. block in quick on INTERNAL_INTERFACE from any to bbb.bbb.bbb.255/32
  1089.  
  1090. # pass traffic out from EXTERNAL_INTERFACE and from INTERNAL_NETWORK
  1091. pass out quick on EXTERNAL_INTERFACE proto tcp/udp from \
  1092. BRIDGE2_EXTERNAL_IP/32 to any keep state
  1093. pass out quick on EXTERNAL_INTERFACE proto icmp from \
  1094. BRIDGE2_EXTERNAL_IP/32 to any keep state
  1095. pass out quick on EXTERNAL_INTERFACE proto tcp/udp from \
  1096. BRIDGE2_INTERNAL_NETWORK/24 to any keep state
  1097.  
  1098. # pass IPSEC traffic for bridge0 and enc1
  1099. pass in quick proto esp from BRIDGE1_EXTERNAL_IP/32 to \
  1100. BRIDGE2_EXTERNAL_IP/32
  1101. pass out quick proto esp from BRIDGE2_EXTERNAL_IP/32 to \
  1102. BRIDGE1_EXTERNAL_IP/32
  1103. pass in quick on enc1 from BRIDGE1_INTERNAL_NETWORK/24 to \
  1104. BRIDGE2_INTERNAL_NETWORK/24
  1105.  
  1106.  
  1107. After configuring both bridges use the following command to flush
  1108. IPF and restart it with the current ruleset:
  1109.        
  1110. # ipf -Fa -f /etc/ipf.rules
  1111.  
  1112.  
  1113. .Benefits of this Technique
  1114.  
  1115.   If you've stuck with the examples this far, you're likely to have a
  1116. functioning IPSEC bridge on your hands. As far as client machines on  
  1117. either internal network know; they are on a LAN with every machine on the
  1118. network (including machines remotely located on the other side of the
  1119. VPN). You should find arp entries for all client machines on each bridge
  1120. box.
  1121.         
  1122.   It should now be possible to install a WINS server (or Samba acting as 
  1123. WINS) on either side of the VPN and have all machines connect to it (thus
  1124. establishing Network Neighborhood for all machines involved).  
  1125.  
  1126.   Any IP-based protocol should function provided that said protocol does
  1127. not mandate passing broadcast traffic (hence the use of WINS to establish
  1128. NetBIOS ease-of-use).
  1129.  
  1130.  
  1131. .Drawbacks not Readily Apparent
  1132.  
  1133. You may have realized that all the machines on both sides of the VPN will
  1134. need to share the same address space to route IP. As with a normal
  1135. physical bridge; normal routing applies.
  1136.  
  1137. Non-IP protocols *will* be transmitted across the VPN unless you include
  1138. the 
  1139.  
  1140.     brconfig blocknonip
  1141.  
  1142.  
  1143. line in your configurations. The provided perl utility does *not* filter
  1144. non-IP traffic by default. 
  1145.  
  1146. [ Note that if you do this, obviously, non-IP (v4, v6, ARP and RARP)
  1147.   traffic gets dropped, so if you want to get your IPX/AppleTalk/foo
  1148.   traffic to pass, you need some tunnelling.  OpenBSD's GRE support
  1149.   would be perfect for this, if only it understood non-IP protocols.
  1150.   tipxd (http://tipxd.sourceforge.net/) will tunnel IPX.  Good luck with
  1151.   anything else.  Really, brconfig should let you filter by ethernet
  1152.   packet type.  Oh well. {ajax} ]
  1153.  
  1154. In Closing
  1155.  
  1156. Enjoy. Pampering Windows clients is, of course; only one use for an IPSEC
  1157. bridge.   
  1158.  
  1159.  
  1160. .Further Reading/Bibliography
  1161.  
  1162.   brconfig(8)
  1163.   vpn(8)
  1164.   ipf(5)
  1165.   Transparent Network Security Policy Enforcement
  1166.     [ http://www.thought.net/jason/bridgepaper ]
  1167.   Using IPSEC and Samba to Integrate Windows Networks 
  1168.     [ http://napalm.firest0rm.org/issue7.html#integ ]
  1169.  
  1170.  
  1171. Signed
  1172.  
  1173.   azure@gh0st.net 
  1174.   http://azure.gh0st.net, http://www.nsacom.net
  1175.  
  1176. _________________________________________________
  1177. ----------------------------------------- - echo8
  1178. [=] 0x06: Security Holes in Sun Cluster 2.x
  1179.  
  1180. Hole #1
  1181. -------
  1182.                 
  1183. Summary 
  1184. -------
  1185.  
  1186. Sun Cluster 2.x (Sun Microsystems' commercial high-availability product
  1187. for Solaris) leaks potentially sensitive information to local or remote
  1188. users.
  1189.  
  1190. Specifics
  1191. ---------
  1192.  
  1193. In a standard Sun Cluster install, there is a service called clustmon
  1194. that runs on port 12000. It is used by the cluster's administrative tool
  1195. (hastat) for the exchange of information between cluster nodes. However,
  1196. the service doesn't do any kind of authentication whatsoever, and can be
  1197. used by any host which can connect to it to gain access to some fairly
  1198. sensitive data. It also has some amusing undocumented features. The
  1199. syntax used interactively is very similar to sendmail's help syntax, but
  1200. if you can't figure it out, the service will happily hold your hand:
  1201.  
  1202. echo8:{501} telnet foobar 12000
  1203. Trying 192.168.0.1...
  1204. Connected to foobar.
  1205. Escape character is '^]'.
  1206. 220  foobar Monitor server version SC 2.1 (98/5/13 V2.1+) (Debug) ready.
  1207. help
  1208. 214- The following commands are recognized:
  1209. 214- NOOP                       - does nothing
  1210. 214- QUIT                       - closes this connection
  1211. 214- PORT inetaddr port         - data addr/port as a sequence of 6
  1212.                                   numbers
  1213. 214- DATE BEGINNING             - start at beginning of time
  1214. 214- DATE NEW                   - start now
  1215. 214- DATE CURRENT               - start with current logfile
  1216. 214- DATE AFTER <datespec>      - specify a starting date
  1217. 214- DATE AFTER <datespec> LOOP - wait for new entries to be appended to
  1218.                                   logfile
  1219. 214- OPEN servicename           - initiate a data stream
  1220. 214- CLOS servicename           - shut down a data stream
  1221. 214- HELP                       - show this list
  1222. 214  Direct comments to cluster-help@sun.com.
  1223.  
  1224. "open syslog" will echo out the entire contents of /var/adm/messages.
  1225.  
  1226. "open haconfig" will provide a listing of all of the other cluster nodes,
  1227. the names of each registered data service and logical host, full paths to
  1228. your start and stop methods, and the current state of your data services
  1229. and logical hosts.
  1230.  
  1231. Because in.mond runs as root out of inetd, both commands will succeed
  1232. regardless of the local permissions on /var/adm/messages or the CCD
  1233. database. Even if you choose NOT to make this information available to
  1234. local users by putting restrictive permissions on the relevant files,
  1235. remote users can still access it.
  1236.  
  1237. "open hastat" will provide all of the information usually provided to
  1238. local superusers via /opt/SUNWcluster/bin/hastat, including:
  1239.  
  1240. * uptime of hosts
  1241. * status of public and private networks
  1242. * names and current locations of logical hosts
  1243. * state of HA monitoring on each logical host
  1244. * States of NAFO groups, including times of most recent failovers
  1245.  
  1246. It's interesting to note that the (local) hastat command is restricted to
  1247. the superuser. However, the network service is universally accessible.
  1248.  
  1249. "open sesame" will tell you that the cave is still blocked (I'm serious,
  1250. try it). 
  1251.  
  1252. All of this information is available to ANY host which can connect to the
  1253. aforementioned port with a telnet client. While none of this really
  1254. constitutes a compromise, it is the sort of information leakage which can
  1255. be useful intelligence for a would-be attacker.
  1256.  
  1257. Workaround
  1258. ----------
  1259.  
  1260. One could trivially use tcp wrappers to keep unauthorized hosts away from
  1261. the port in question. 
  1262.  
  1263. [ One could also (probably) create a 'mond' user and run in.mond as that
  1264.   instead of as root.  You'll probably have to chown lots of files to keep
  1265.   some of the functionality, but, price you pay. {ajax} ]
  1266.  
  1267. Vendor Response 
  1268. ---------------
  1269.  
  1270. The vendor was notified on October 31, 2000. When I contacted Sun and
  1271. opened a case, the individual who responded to my case dismissed the
  1272. problem by saying that "the product was not intended for use in hostile
  1273. environments or on networks that have untrusted users." Sun also
  1274. suggested that perhaps they will remove the help functions from upcoming
  1275. versions.
  1276.  
  1277.  
  1278. Hole #2
  1279. -------
  1280.  
  1281. Summary 
  1282. -------
  1283.  
  1284. The HA-NFS data service (a component of Sun Cluster 2.x) has a security
  1285. hole that can allow local users to read any file on the system, regardless
  1286. of the permissions on that file. In order to exploit the hole, a clustered
  1287. system must be using HA-NFS, and the attacker must have a local account.
  1288.  
  1289. Specifics
  1290. ---------
  1291.  
  1292. On a host running HA-NFS, the file called
  1293. /var/opt/SUNWcluster/fm/fmstatus/nfs/<logicalhostname>/status is created
  1294. by Sun Cluster with permissions set to 666.
  1295.  
  1296. The directory above it
  1297. (/var/opt/SUNWcluster/fm/fmstatus/nfs/<logicalhostname>) is created mode
  1298. 777.
  1299.  
  1300. The status file is read by in.mond to display the status of the HA-NFS
  1301. service. in.mond follows symbolic links. in.mond is most commonly
  1302. executed when called by the hastat utility, which can only be run by the
  1303. superuser. However, as described in hole #1, any remote user can connect
  1304. directly to in.mond and make full use of it from a telnet client.
  1305.  
  1306. To exploit this hole to view a file to which he does not have read access,
  1307. a local (unprivileged) user can do the following:
  1308.  
  1309. $ cd /var/opt/SUNWcluster/fm/fmstatus/nfs/<logicalhostname>
  1310. $ rm status
  1311. $ ln -s /etc/shadow status
  1312. $ telnet localhost 12000
  1313. <once connected to the in.mond service>
  1314. open hastat
  1315.  
  1316. ... and watch as the shadow file is read out to stdout ...
  1317.  
  1318. Workaround
  1319. ----------
  1320.  
  1321. Change the permissions on the files in question. Use tcp wrappers to keep
  1322. unauthorized hosts away from in.mond.
  1323.  
  1324. Vendor Response
  1325. ---------------
  1326.  
  1327. Sun was notified on November 22, 2000. As yet, there has been no response.
  1328.  
  1329. Comments
  1330. --------
  1331.  
  1332. High-availability products should not weaken the security of the systems
  1333. on which they run. Despite what Sun may say, giving out your system logs
  1334. and configuration specifics to unauthorized remote users weakens the
  1335. security of a system. Removing the help features amounts to security
  1336. through obscurity. I was able to very trivially discover at least one
  1337. completely undocumented feature in in.mond ("open sesame"), so I have no
  1338. reason to believe there are not others.
  1339.  
  1340. The more recent discovery of the second hole only reaffirms the idea that
  1341. there are no small vulnerabilities. Some minor holes can be leveraged to
  1342. cause further harm or gain additional access. The two described above are
  1343. a textbook illustration of this concept.
  1344.  
  1345. Please address comments to echo8@firest0rm.org. 
  1346.  
  1347. [ Wow, zero-day 'sploits! {kynik} ]
  1348.  
  1349. _____________________________
  1350. --------------------- - kynik
  1351. [=] 0x07: Music Reviews
  1352.  
  1353. This space for rent.
  1354.  
  1355. No, seriously, I haven't been able to get enough response from the core
  1356. contributors to review any more music. If you have a good grasp of the
  1357. english language (spelling and grammar) and love music, drop me a line.
  1358. I've got a pile of miscellaneous stuff I'd like other people to review,
  1359. and nobody seems to be interested. If worse comes to worse, I'll do the
  1360. reviews entirely on my own. (But we don't want that, do we?)
  1361.  
  1362. [ In fact, you don't even need a good grasp of English. We'll take random
  1363.   street lunatics if their review is funny enough. {ajax} ]
  1364.  
  1365. _________________
  1366. -----------------
  1367. [=] 0x09: Credits
  1368.  
  1369.                Editor:  Kynik    <kynik@firest0rm.org>
  1370.             Co-Editor:  ajax     <ajax@firest0rm.org>
  1371. Article Contributions:  Flame0ut <napalm@firest0rm.org>
  1372.                         Orbitz   <orbitz@firest0rm.org>
  1373.                         _azure   <azure@gh0st.net>
  1374.                         echo8    <echo8@firest0rm.org>
  1375.  
  1376. To subscribe to this 'zine:
  1377.   email napalm@firest0rm.org with a subject of SUBSCRIBE
  1378.  
  1379. To unsubscribe:
  1380.   email napalm@firest0rm.org with a subject of UNSUBSCRIBE
  1381.  
  1382. Or find us online at:
  1383.   http://napalm.firest0rm.org/
  1384.  
  1385. Submissions, questions, comments, and constructive chaos may also be
  1386. directed to kynik@firest0rm.org or any of the contributors
  1387.  
  1388. .n8! - eof
  1389.  
  1390.