Don't like ads? PRO users don't see any ads ;-)
Guest

#School4lulz Secure Paste on setting up Vmware/Linux

By: anontangodown on Jul 24th, 2011  |  syntax: None  |  size: 42.80 KB  |  hits: 856  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #School4Lulz Secure Paste Archived by AnontangoDown
  2.  
  3. Link: https://www.securepaste.com/decrypt_data.php?id=d0Bn3ABaxEZc&password=blackHatAcad
  4.  
  5. Message: d0Bn3ABaxEZc
  6.  Posted by: d1zzY on Jul 24 2011, 10:07:00
  7.  
  8.     #######################################
  9.  
  10.       VM PREPERATION
  11.  
  12.      #######################################
  13.  
  14.      If you are not using VM software like VMWare or Virtualbox, you can safely
  15.  
  16.      ignore this. Otherwise, make sure your VM has:
  17.  
  18.      -Around 512mb to a gig of RAM
  19.  
  20.      -At least 10GB HDD
  21.  
  22.      -Networking features enabled
  23.  
  24.      -Preferably multiple cores on an x86_64 processor
  25.  
  26.      #######################################
  27.  
  28.  
  29.  
  30.      #######################################
  31.  
  32.       DISK/ETC PREP
  33.  
  34.      #######################################
  35.  
  36.      ls /dev|grep sd
  37.  
  38.      cfdisk /dev/sda
  39.  
  40.      Create 100MB Partition Bootable at the Beginning
  41.  
  42.      Create 2048MB Partition at the beginning
  43.  
  44.      Create remaining free space partition at the beginning
  45.  
  46.      # Choose to Write tables to disk
  47.  
  48.      # Choose to Quit cfdisk
  49.  
  50.      mkfs.ext2 /dev/sda1
  51.  
  52.      mkswap /dev/sda2
  53.  
  54.      mkfs.reiserfs /dev/sda3
  55.  
  56.      mount -t reiserfs /dev/sda3 /mnt/gentoo ; cd /mnt/gentoo
  57.  
  58.      wget http://gentoo.arcticnetwork.ca/releases/x86/current-stage3/stage3-i686-20110614.tar.bz2
  59.  
  60.      # for the below line, you can simply press the TAB button after stage3 and it will automatically complete the command, just press enter to confirm it
  61.  
  62.      tar xvpjf stage3*
  63.  
  64.      swapon /dev/sda2
  65.  
  66.      cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
  67.  
  68.  
  69.  
  70.      # make sure you can access network here, try ping google.com or links google.command
  71.  
  72.      # if it isn't working, try to:
  73.  
  74.      # ifconfig eth0 down && ifconfig eth0 up
  75.  
  76.      # dhcpcd eth0
  77.  
  78.      # you might need to do this each time you reboot
  79.  
  80.      #######################################
  81.  
  82.  
  83.  
  84.      ######################################
  85.  
  86.       BASE SYSTEM INSTALL + CONFIG
  87.  
  88.      ######################################
  89.  
  90.  
  91.  
  92.      grep -ci "processor" /proc/cpuinfo
  93.  
  94.      # remember the number in the output of this command
  95.  
  96.  
  97.  
  98.      cd /mnt/gentoo/usr/
  99.  
  100.      wget http://gentoo.arcticnetwork.ca/releases/snapshots/current/portage-latest.tar.bz2
  101.  
  102.      tar xvjf portage-latest.tar.bz2
  103.  
  104.      
  105.  
  106.      cd /mnt/gentoo/etc/
  107.  
  108.      nano make.conf
  109.  
  110.  
  111.  
  112.      #modify the make.conf as follows: (NOTE:do not modify the CHOST, this will cause problems)
  113.  
  114.  
  115.  
  116.      CFLAGS="-fstack-protector-all -fforce-addr -Os -pipe -march=native"
  117.  
  118.      CXXFlags="${CFLAGS}"
  119.  
  120.  
  121.  
  122.  
  123.  
  124.      FEATURES="metadata-transfer sandbox candy parallel-fetch"
  125.  
  126.  
  127.  
  128.      USE="gtk truetype postgres freetype jpg jpeg png gif imap ttf winscp passwd scp X gnutls mysql v4l2 extras lisp threads ithreads acpi bash-completion bzip2 crypt cracklib css ctype apache2 curl curlwrappers dbus encode ftp gcj gd geoip udev ipv6 lua ncurses nsplugin python readline sockets socks5 sqlite sse sse2 ssl suid unicode vim-syntax xml php perlsuid"
  129.  
  130.  
  131.  
  132.      #Replace Y with the output of the grep command and X with the returned number +1. For one core, you'd have "--jobs=1" and "-j2".
  133.  
  134.  
  135.  
  136.      MAKEOPTS="-jX -s"
  137.  
  138.  #   Only use the below line if you have a multicore CPU or multiple processors
  139.  
  140.  #   EMERGE_DEFAULT_OPTS="--jobs=Y --load-average=1.5"
  141.  
  142.      PORTAGE_NICENESS="12"
  143.  
  144.  
  145.  
  146.      # ^x Y Enter to save and quit, this is CTRL+X -> Y -> RETURN KEY
  147.  
  148.  
  149.  
  150.      #######################################
  151.  
  152.       CHROOTING
  153.  
  154.      #######################################
  155.  
  156.      #= PLEASE RETURN TO THIS EVERY TIME  =#
  157.  
  158.      #= THAT YOU RESTART, UNTIL YOU ARE   =#
  159.  
  160.      #= TOTALLY FINISHED                  =#
  161.  
  162.      #######################################
  163.  
  164.      mount /dev/sda3 /mnt/gentoo
  165.  
  166.      swapon /dev/sda2
  167.  
  168.      mount /dev/sda1 /mnt/gentoo/boot
  169.  
  170.      mount -o bind /dev /mnt/gentoo/dev
  171.  
  172.      mount -t proc none /mnt/gentoo/proc
  173.  
  174.      chroot /mnt/gentoo /bin/bash --login
  175.  
  176.      gcc-config 1 #(Do this the 1st time ONLY)
  177.  
  178.      env-update
  179.  
  180.      export PS1="chroot) $PS1"
  181.  
  182.      # the above line will remind you where you are :)
  183.  
  184.      #######################################
  185.  
  186.  
  187.  
  188.      #######################################
  189.  
  190.       INSTALLING SOFTWARE
  191.  
  192.      #######################################
  193.  
  194.  
  195.  
  196.      ### You may need this if you can't currently ping
  197.  
  198.      echo nameserver 4.2.2.1 > /etc/resolv.conf
  199.  
  200.      echo nameserver 4.2.2.2 >> /etc/resolv.conf
  201.  
  202.      ###
  203.  
  204.  
  205.  
  206.      emerge -q --sync
  207.  
  208.      # if it tells you that an update to portage is availible then do the following
  209.  
  210.      emerge -q portage
  211.  
  212.      # otherwise, continue from here
  213.  
  214.  
  215.  
  216.      emerge -q axel
  217.  
  218.  
  219.  
  220.      nano -w /etc/make.conf
  221.  
  222.  
  223.  
  224.      # put this at the bottom of make.conf
  225.  
  226.      FETCHCOMMAND="/usr/bin/axel -n 8 -o /\${DISTDIR}/\${FILE} -a \${URI}"
  227.  
  228.      RESUMECOMMAND="/usr/bin/axel -n 8 -o /\${DISTDIR}/\${FILE} -a \${URI}"
  229.  
  230.  
  231.  
  232.      # ^x Y Enter again to save and quit
  233.  
  234.  
  235.  
  236.      emerge -qN pciutils coreutils baselayout hardened-sources world
  237.  
  238.  
  239.  
  240.      ###########################################
  241.  
  242.  
  243.  
  244.      ###########################################
  245.  
  246.       ENCRYPTED HOME
  247.  
  248.      ###########################################
  249.  
  250.      mkdir /crypt
  251.  
  252.      touch /crypt/home.dm
  253.  
  254.  
  255.  
  256.      echo "sys-fs/cryptsetup static-libs" >> /etc/portage/package.use
  257.  
  258.      emerge -q cryptsetup
  259.  
  260.  
  261.  
  262.      ### replace XXX in the line below with the size in GB (Gigabytes) you want your home to be.
  263.  
  264.      ### if you are not sure, run 'df -h' and use perhaps a quarter of the size of sda3
  265.  
  266.      dd if=/dev/zero of=/crypt/home.dm bs=1024 count=$(head -1 /etc/make.conf|awk '{print XXX * 1024^2}')
  267.  
  268.      losetup /dev/loop1 /crypt/home.dm
  269.  
  270.      cryptsetup luksFormat -h whirlpool -c blowfish /dev/loop1
  271.  
  272.      cryptsetup luksOpen /dev/loop1 home
  273.  
  274.      emerge -q reiserfsprogs
  275.  
  276.      mkfs.reiserfs /dev/mapper/home
  277.  
  278.      mount -o loop /dev/mapper/home /home
  279.  
  280.  
  281.  
  282.      nano /etc/init.d/home
  283.  
  284.  
  285.  
  286.      #make the file look like this:
  287.  
  288.  
  289.  
  290.  
  291.  
  292.      #########
  293.  
  294.      #!/sbin/runscript
  295.  
  296.      # Copyright 1999-2011 Gentoo Foundation
  297.  
  298.      # Distributed under the terms of the GNU General Public License v2
  299.  
  300.      # $Header: $
  301.  
  302.      depend() {
  303.  
  304.      true
  305.  
  306.      }
  307.  
  308.      start() {
  309.  
  310.      losetup /dev/loop1 /crypt/home.dm
  311.  
  312.      cryptsetup luksOpen /dev/loop1 home
  313.  
  314.      mount -o loop /dev/mapper/home /home
  315.  
  316.      }
  317.  
  318.      stop() {
  319.  
  320.      umount /home
  321.  
  322.      cryptsetup luksClose home
  323.  
  324.      losetup -d /dev/loop1
  325.  
  326.      }
  327.  
  328.      restart() {
  329.  
  330.      stop
  331.  
  332.      start
  333.  
  334.      }
  335.  
  336.      ##########
  337.  
  338.  
  339.  
  340.  
  341.  
  342.      chmod +x /etc/init.d/home
  343.  
  344.      rc-update add home default
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.      #################### NOTE ###################
  353.  
  354.  
  355.  
  356.      # if you have restarted, do the following
  357.  
  358.      mount /dev/sda3 /mnt/gentoo
  359.  
  360.      mount /dev/sda1 /mnt/gentoo/boot
  361.  
  362.      swapon /dev/sda2
  363.  
  364.      mount -t proc none /mnt/gentoo/proc
  365.  
  366.      mount -o bind /dev /mnt/gentoo/dev
  367.  
  368.      chroot /mnt/gentoo /bin/bash --login
  369.  
  370.      #################################################
  371.  
  372.  
  373.  
  374.      #################################################
  375.  
  376.       KERNEL
  377.  
  378.      #################################################
  379.  
  380.      NOTE: DOUBLE CHECK THAT YOU ARE IN A CHROOT BEFORE
  381.  
  382.      DOING THIS! ls /mnt/gentoo should return FILE NOT
  383.  
  384.      FOUND, otherwise do what is in the above NOTE block
  385.  
  386.      #################################################
  387.  
  388.      cd /usr/src/linux
  389.  
  390.  
  391.  
  392.      groupadd audit
  393.  
  394.      grep audit /etc/group
  395.  
  396.      groupadd blackhole
  397.  
  398.      grep blackhole /etc/group
  399.  
  400.  
  401.  
  402.      # confirm you get stuff returned to you after each grep. these numbers you're seeing are GIDs for RBAC
  403.  
  404.  
  405.  
  406.      groupadd clients
  407.  
  408.      grep clients /etc/group
  409.  
  410.      groupadd services
  411.  
  412.      grep services /etc/group
  413.  
  414.  
  415.  
  416.      #again, confirm you are getting information when you grep.  you prolly wanna write those id's down
  417.  
  418.  
  419.  
  420.      wget http://paste.pocoo.org/raw/430946
  421.  
  422.      mv 430946 .config
  423.  
  424.  
  425.  
  426.      # now you can
  427.  
  428.      emerge -q wgetpaste
  429.  
  430.      lspci -n | wgetpaste
  431.  
  432.      # open provided url in browser, paste into the following website
  433.  
  434.      # or
  435.  
  436.      passwd
  437.  
  438.      # type in a password twice
  439.  
  440.      /etc/init.d/sshd start
  441.  
  442.      # download PuTTy on your main/host pc and use it to connect to the ipaddress of the vm/box, you can find out the ip with
  443.  
  444.      ifconfig
  445.  
  446.      # you connect on port 22 (ssh)
  447.  
  448.      lspci -n
  449.  
  450.      # copy and paste this to the following website
  451.  
  452.  
  453.  
  454.      # http://kmuto.jp/debian/hcl/
  455.  
  456.      # if you need to, take a note of each entry under 'drivers'
  457.  
  458.  
  459.  
  460.      make menuconfig
  461.  
  462.  
  463.  
  464.      # search for 'dm_crypt' with the / key from the main menu - this should open a search box.
  465.  
  466.      # you will see the location of dm_crypt in the menu, and whether it is [=y] (enabled) or [=n] (disabled)
  467.  
  468.      # you want to find it and enable it. do not set it as 'M', that will make it a module and for security reasons you are not using
  469.  
  470.      # loadable modules.
  471.  
  472.      # do this for each driver on the above website, and make sure that they are all enabled
  473.  
  474.      # some, such as graphics, can be safely missed out (get vesa, instead) - if you have any worries, ask in #questions on irc
  475.  
  476.      # replace every - in a driver name with a _
  477.  
  478.      # also, verify that all the following settings are correct:
  479.  
  480.  
  481.  
  482.      - Disable loadable module support
  483.  
  484.      - Disable virtualization on the kernel
  485.  
  486.      - Under general options, change kernel compression mode to lzma
  487.  
  488.      - Under processor type and features, you'll want to either A. Put the processor type, if it's in the list or B. Select generic if unsure
  489.  
  490.      - In filesystems, you only want reiserfs depending on how you set it up. You do not want ext2 -- if it is enabled, (Second Extended FS Support), DISABLE THIS.
  491.  
  492.      - Under security options, enable grsecurity
  493.  
  494.      - Under address space protection
  495.  
  496.      - Enable active kernel exploit response
  497.  
  498.      - Under RBAC,enable 'Hide Kernel Processes'
  499.  
  500.      - Under filesystem protections, restrict /proc to user only
  501.  
  502.      - Under kernel auditing, enable every option except 'ELF TEXT Relocation
  503.  
  504.      - Put the gid to 'audit'
  505.  
  506.      - Enable everything under network protections
  507.  
  508.      - Put the gid to 'services' in 'deny client sockets for group' gid
  509.  
  510.      - Put the gid to 'clients' in 'deny server sockets for group' gid
  511.  
  512.      - Put the gid to blackhole in the 'deny all sockets to any group' gid
  513.  
  514.      - Under logging options, "Add source ip addresses to AVC SeLinux messages"
  515.  
  516.      - Under pax control, change 'MAC system integration' to hook
  517.  
  518.      - Under misc. hardening features, You'll want to enable everything
  519.  
  520.      - Under non-executable pages,Enforce non-executable pages' is enabled
  521.  
  522.      - Back in the main security options window, enable 'Restrict unpriviledged access to the kernel syslog'
  523.  
  524.      - Enable Integrity Measurement Architecture
  525.  
  526.      - Under cryptographic api, we want aes of all flavors, whirlpool, and blowfish
  527.  
  528.      - Uncheck the Hardware Crypto Devices support
  529.  
  530.      - Under device drivers -> multi device support, enable dm_crypt
  531.  
  532.      - Block devices ->loopback device support, enable cryptoloop support
  533.  
  534.      - Under kernel hacking enable strict copy size checks and disable kernel debugging
  535.  
  536.      - Under kernel hacking disable kernel debugging
  537.  
  538.      - Put the gid to 'audit' in the proc gid as well as the kernel auditing pid
  539.  
  540.  
  541.  
  542.      # exit, saving the config
  543.  
  544.  
  545.  
  546.      # put the number of processors you have +1 instead of ?, for example -j5 if you have 4 cores
  547.  
  548.      make -j?
  549.  
  550.  
  551.  
  552.      # make sure boot is mounted, this should NOT say file not found, exit from chroot and remount /mnt/gentoo/boot, then chroot in again if you get an error
  553.  
  554.      ls /boot
  555.  
  556.  
  557.  
  558.      # replace XXX below with your architecture (x86 for 32bit, x86_64 for 64bit)
  559.  
  560.      cp /usr/src/linux/arch/XXX/boot/bzImage /boot/bzImage
  561.  
  562.      # if you ever need to repeat this, make clean before reconfiguring your kernel and adding/removing stuff
  563.  
  564.      # you can read much more about kernel configuration at kernel-seeds.org, this website contains premade, stripped
  565.  
  566.      # kernels and step-by-step guides on configuring your own kernel from scratch, with detailed notes on every option
  567.  
  568.      # it's great to check out if you are unsure about anything, and will really help the learning process :)
  569.  
  570.      #####################################################
  571.  
  572.  
  573.  
  574.      #####################################################
  575.  
  576.       FINAL CONFIGURATION
  577.  
  578.      #####################################################
  579.  
  580.  
  581.  
  582.      emerge -q syslog-ng vixie-cron strace gdb ruby nemesis
  583.  
  584.  
  585.  
  586.      grep -v rootfs /proc/mounts > /etc/mtab
  587.  
  588.      # XXX below will be x86 or x86_64 depending upon whether your system is 32 or 64 bit
  589.  
  590.      cp arch/XXX/boot/bzImage /boot
  591.  
  592.      nano /etc/fstab
  593.  
  594.  
  595.  
  596.      # change the ROOT and SWAP lines to look like the following
  597.  
  598.  
  599.  
  600.      #####
  601.  
  602.      /dev/sda3               /               reiserfs                noatime         0 1
  603.  
  604.      /dev/sda2               none            swap           sw              0 0
  605.  
  606.      #####
  607.  
  608.      # delete the /dev/BOOT line
  609.  
  610.      # and CTRL+X -> Y
  611.  
  612.  
  613.  
  614.      #####################################################
  615.  
  616.       BOOTLOADER
  617.  
  618.      #####################################################
  619.  
  620.  
  621.  
  622.      emerge -q grub
  623.  
  624.      grub-install --no-floppy /dev/sda
  625.  
  626.      nano -w /boot/grub/grub.conf
  627.  
  628.  
  629.  
  630.      # uncomment the splash image and ensure the below is in the file
  631.  
  632.      kernel /boot/bzImage root=/dev/sda3
  633.  
  634.      root (hd0,0)
  635.  
  636.      # CTRL+X -> Y
  637.  
  638.  
  639.  
  640.      passwd root
  641.  
  642.      # choose a password, type it twice
  643.  
  644.  
  645.  
  646.      emerge -q pump
  647.  
  648.      rc-update add vixie-cron default
  649.  
  650.      rc-update add syslog-ng default
  651.  
  652.      rc-update add home default
  653.  
  654.      source /etc/profile
  655.  
  656.      env-update at this time
  657.  
  658.  
  659.  
  660.      # now exit from the chroot for the final step
  661.  
  662.      exit
  663.  
  664.      # and ensure you have all the device nodes you need
  665.  
  666.      umount /mnt/gentoo/dev
  667.  
  668.      # make sure you do NOT accidentally umount /mnt/gentoo above, we just want to umount dev!
  669.  
  670.      cp -a /dev/* /mnt/gentoo/dev/
  671.  
  672.  
  673.  
  674.      # once you're done, restart the system
  675.  
  676.      # to get networking working
  677.  
  678.      ifconfig eth0 down && ifconfig eth0 up
  679.  
  680.      pump -i eth0
  681.  
  682.  
  683.  
  684.      # to get the network working, you may need to overwrite resolv.conf as mentioned earlier
  685.  
  686.      echo nameserver 4.2.2.1 > /etc/resolv.conf
  687.  
  688.      echo nameserver 4.2.2.2 >> /etc/resolv.conf
  689.  
  690.      ###
  691.  
  692.  
  693.  
  694.      # install vim
  695.  
  696.      emerge -q vim
  697.  
  698.      # or emacs
  699.  
  700.      emerge -q emacs
  701.  
  702.  
  703.  
  704.      # and you'll have to look up a tutorial on these yourself or ask for help in choosing in #questions :) try getting vim and typing vimtutor
  705.  
  706.  
  707.  
  708.      ############################################
  709.  
  710.       XSERVER - RAZ0R
  711.  
  712.      ############################################
  713.  
  714.      --------NEVER RUN XSERVER AS ROOT-----------
  715.  
  716.  
  717.  
  718.      -Make sure your home is encrypted before we begin
  719.  
  720.  
  721.  
  722.      vi /etc/make.conf
  723.  
  724.      ### add the following line with the correct driver for your card, ie. noveau for nvidia, radeon for radeon, vmware for vmware, virtualbox for virtualbox or intel for intel
  725.  
  726.      VIDEO_CARDS="driver"
  727.  
  728.  
  729.  
  730.      # also add the following line, if you are on a PC or VM
  731.  
  732.      INPUT_DEVICES="evdev"
  733.  
  734.      # or this line if you are on a laptop
  735.  
  736.      INPUT_DEVICES="evdev synaptics"
  737.  
  738.  
  739.  
  740.      -Make sure that the correct driver for your graphics card is built into the kernel, return to the kernel section to do this if you have not already.
  741.  
  742.      -Make sure you have udev in your USE flag in /etc/make.conf
  743.  
  744.  
  745.  
  746.      emerge -q xorg-drivers
  747.  
  748.      emerge -q xorg-server
  749.  
  750.      emerge -q fluxbox
  751.  
  752.      emerge -q aterm # transparent terminal!
  753.  
  754.      emerge -q conky # system monitoring tool
  755.  
  756.      emerge -q sudo
  757.  
  758.  
  759.  
  760.      # edit /etc/sudoers to your own preference, you only need to remove the comment before the %wheel sudo access with NOPASSWD, OR the one using password. make sure to add the user to the wheel group with gpasswd -a wheel username
  761.  
  762.  
  763.  
  764.      #also add the following line
  765.  
  766.      %wheel ALL = (firefox) NOPASSWD: /usr/lib64/firefox/firefox
  767.  
  768.      # if you are on a 32bit installation, use lib32 instead
  769.  
  770.  
  771.  
  772.      mkdir -p /etc/X11/xinit
  773.  
  774.      echo "exec startfluxbox" > /etc/X11/xinit/xinitrc
  775.  
  776.  
  777.  
  778.      # For virtualbox, check out http://en.gentoo-wiki.com/wiki/Virtualbox_Guest for a guide to enable copy-paste between host/vm etc
  779.  
  780.  
  781.  
  782.      /etc/init.d/udev start
  783.  
  784.      rc-update add udev sysinit
  785.  
  786.  
  787.  
  788.      # If you don't have a basic user account already, make one now.
  789.  
  790.  
  791.  
  792.  
  793.  
  794.      exit # from root
  795.  
  796.  
  797.  
  798.      #login as normal user
  799.  
  800.      startx
  801.  
  802.  
  803.  
  804.      #open a terminal by right clicking and choosing to open xterm
  805.  
  806.      sudo useradd -m -g clients -U firefox
  807.  
  808.  
  809.  
  810.      # NOTE: The following script is a little buggy and prevents firefox from launching if it takes more than 1 second for it to read the Xauthority file, so if that happens just bump up the sleep value.
  811.  
  812.      # you could also create sandfox in your ~/bin as described under the security section below, in that case just replace /usr/bin/sandfox with ~/bin/sandfox from now on
  813.  
  814.      sudo vi /usr/bin/sandfox
  815.  
  816.  
  817.  
  818.      ### add the following into that file
  819.  
  820.      cp $HOME\/.Xauthority /tmp/$USER\.firefox.Xauthority
  821.  
  822.      chmod 777 /tmp/$USER\.firefox.Xauthority
  823.  
  824.      ( ( env XAUTHORITY=/tmp/$USER\.firefox.Xauthority sudo -u firefox /usr/lib64/firefox/firefox $1 & ) & )
  825.  
  826.      sleep 1
  827.  
  828.      rm /tmp/$USER\.firefox.Xauthority
  829.  
  830.      ###
  831.  
  832.  
  833.  
  834.      sudo chmod +x /usr/bin/sandfox
  835.  
  836.  
  837.  
  838.      # NOTE: all history and profiles will be saved in firefox's home directory instead of yours, take note of this. you can pass paramaters such as -private by running, eg /usr/bin/sandfox -private
  839.  
  840.  
  841.  
  842.      sudo mkdir -p /etc/portage
  843.  
  844.      sudo echo "www-browser/firefox hardened" >> /etc/portage/package.use
  845.  
  846.  
  847.  
  848.      sudo emerge -q tint2 tintwizard
  849.  
  850.  
  851.  
  852.      vi ~/.fluxbox/init
  853.  
  854.      # change session.screen0.toolbar.visible: to false
  855.  
  856.  
  857.  
  858.      sudo emerge -q xcompmgr # dropshadows and fading
  859.  
  860.  
  861.  
  862.      vi ~/.fluxbox/startup
  863.  
  864.      ### add, at the end of Applications you want to start with Fluxbox
  865.  
  866.      xcompmgr -c -r 6 -f -D 5 -t -9 -l -9 &
  867.  
  868.      tint2 &
  869.  
  870.      ### make sure the last line is exec fluxbox
  871.  
  872.  
  873.  
  874.      vi ~/.fluxbox/menu
  875.  
  876.  
  877.  
  878.      # change every occurance of xterm to 'aterm -tr -trsb -sh 40' without the '', if xterm is being used to execute something else, add -e so 'aterm -tr -trsb -sh 40 -e sudo -s' for an automatic root terminal.
  879.  
  880.      # add sandfox, it should be pretty easy to figure out
  881.  
  882.  
  883.  
  884.      ##PROTIPS ON PROXYCHAINS##
  885.  
  886.      You can use submenus for sandfox, so you can make different choices for features as you launch. For example, you could look at making a sandfox-tor selection or sandfox-i2p one, or maybe a sandfox-proxy one. For an easy way to tunnel any program through a socks5 proxy, check out proxychains, though the script might need a little modification.
  887.  
  888.  
  889.  
  890.      You would change sudo -u firefox /usr/lib64/firefox/firefox to sudo -u firefox proxychains /usr/lib64/firefox/firefox, or add proxychains before the executable.
  891.  
  892.  
  893.  
  894.      Also, if you want to use a VPS or a SSH as a SOCKS5 tunnel with proxychains, just do ssh -D 8888 user@server.com and configure proxychains to use 8888 - also known as a GRE tunnel.
  895.  
  896.  
  897.  
  898.      ##ENDPROTIPS##
  899.  
  900.  
  901.  
  902.      # if you want to change your MAC address (physical network address) every boot, for security reasons, get the following package
  903.  
  904.      emerge -q macchanger
  905.  
  906.  
  907.  
  908.      # now you can either do the following manually, or go to the SERVICES section to find out how runscripts work, so you can set one up to do this every boot! note: bringing eth0 down will take down your internet connection, temporarily. if eth0 is not your network interface, check ifconfig and use the one connected to the internet.
  909.  
  910.      ### BEGIN MAC CHANGE
  911.  
  912.      ifconfig eth0 down
  913.  
  914.      macchanger -r eth0
  915.  
  916.      ifconfig eth0 up
  917.  
  918.      ### END MAC CHANGE
  919.  
  920.  
  921.  
  922.      # NOTE: For fluxbox themes you can check out box-looks.org
  923.  
  924.  
  925.  
  926.  
  927.  
  928.      ############################################
  929.  
  930.       BASH
  931.  
  932.      ############################################
  933.  
  934.  All the bash information should be in bash01_protected.pdf, please ask an op for the password if you require it. If you require the file itself, give your secure email address to an op to be added to the list.
  935.  
  936.  
  937.  
  938. Part 1: Reading files
  939.  
  940.  The basic file reader is cat. Cat means conCATonate, and it displays a file. It doesn't actually alter the displayed text in any way, so is useful for small files, but does not scale well.
  941.  
  942. A step up from cat is the more command, more has been around for a while. It allows you to read page by page, extended versions can allow search, too.
  943.  
  944.  The less command is again, one step up from more. Less is a newer version of more that allows for scrolling. This is great for larger files and logs that won't fit in the backbuffer.
  945.  
  946.  head and tail will display just the first or last couple of lines, depending on the value of the -n switch you pass to them. tail -n 2 /etc/passwd, for example, will show the last two lines from the file /etc/passwd. You can use head and tail in more advanced ways, for example tail -n +2 will skip the first line of a file.
  947.  
  948.  Grep will find patterns in files, ie. grep root /etc/passwd will find any lines in /etc/passwd that contain root and print them to stdout (standard out, ie they will be pritned on the screen by default)
  949.  
  950.  
  951.  
  952.  Part 2: Navigation
  953.  
  954.  cd is change directory, using cd /usr/src/linux will set your current working directory (viewable in prompt or with pwd) to /usr/src/linux.
  955.  
  956.  
  957.  
  958.  # at this point, Sav had some network issues and was unable to continue describing the commands - please continue with the PDF on your own :)
  959.  
  960.  
  961.  
  962.  Sav makes a few suggestions:
  963.  
  964.  - touch [filename] &&
  965.  
  966.  # This will create the named file if it doesn't exist, or exit if it does exist and is read only. Otherwise it updates the timestamp.
  967.  
  968.  - time [command]
  969.  
  970.  # This will 'time' the command, it will give you the cpu time in real terms that it took to execute that command, allowing you to do a sort of rudimentary benchmark.
  971.  
  972.  - tac [filename]
  973.  
  974.  # This will print a file in reverse, tac is to tail what cat is to head.
  975.  
  976.  - directing output to file
  977.  
  978.  # Using > or >> you can direct stdout (standard output, ie text) to any file. > will overwrite any currently existing file, >> will append the text to the end of an existing file or create a file if it doesn't exist. An example is lspci > hardwaredevices or man bash >> /root/bashmanual
  979.  
  980.  - directing output to another command
  981.  
  982. # Using | (a pipe), you can direct the output of one command to another, and even chain multiple commands together, using both pipes and appends/overwrites. An example of this would be cat /usr/src/linux/.config | wgetpaste | grep pocoo >> kernelurl (this would print your kernel config to wgetpaste, which would upload it and print a url and some extra info. Only the url line would match the grep, and this line would be added onto the end of the kernelurl file in the current working directory.
  983.  
  984.  Q&A:
  985.  
  986.  - Is it better to use grep or egrep for use with regex?
  987.  
  988.  # grep is faster, keep things as simple as possible (ie. use multiple simple greps rather than one egrep where possible).
  989.  
  990.  
  991.  
  992.     ############################################
  993.  
  994.       SCREEN
  995.  
  996.      ############################################
  997.  
  998.      Screen is a useful terminal multiplexer, similar to BSD's tmux. It allows you to open multiple virtual console sessions in the same shell, and detach-attach to them at will. Sessions in screen preserve through logouts and connection drops, in fact, it's very hard to lose a session unless you shutdown the machine. Screen sessions are extremely useful when connecting to a server through ssh, as if you lose your session you need only re-attach to your screen.
  999.  
  1000.  
  1001.  
  1002.      #To start using screen, you must first install it:
  1003.  
  1004.      emerge -q screen
  1005.  
  1006.  
  1007.  
  1008.      #Now start a screen session called 'testsession'
  1009.  
  1010.      screen -S testsession
  1011.  
  1012.  
  1013.  
  1014.      #A new terminal will open - this is your screen session. Press the following key combination:
  1015.  
  1016.      CTRL+a then d
  1017.  
  1018.  
  1019.  
  1020.      #The terminal will disappear - don't worry, it's just running in the background. List your screens with:
  1021.  
  1022.      screen -ls
  1023.  
  1024.  
  1025.  
  1026.      #Notice the numbers.testsession - this is the ID of your screen session. Since you only have 1, you can now reattach to it with:
  1027.  
  1028.      screen -r
  1029.  
  1030.  
  1031.  
  1032.      #Now create another tab in your screen. Use the following key combination:
  1033.  
  1034.      CTRL+a then c
  1035.  
  1036.  
  1037.  
  1038.      #Check the window list
  1039.  
  1040.      CTRL+a then SHIFT+' # ie. CTRL+a then "
  1041.  
  1042.  
  1043.  
  1044.      # Notice the pattern? CTRL+a tells screen to wait for a command. You will now have a list of windows, showing your terminals. Choose one and press return to switch to it.
  1045.  
  1046.  
  1047.  
  1048.      ls -l
  1049.  
  1050.  
  1051.  
  1052.      CTRL+a then "
  1053.  
  1054.  
  1055.  
  1056.      CTRL+a then SHIFT+a
  1057.  
  1058.  
  1059.  
  1060.      # You can now give your current tab a name - call it 'ls' or something. Note that if you forget any of these commands, you can type:
  1061.  
  1062.  
  1063.  
  1064.      CTRL+a then ? # for a list of commands
  1065.  
  1066.  
  1067.  
  1068.      # You can now switch between your screens, start some new ones. Let's go off on a tangent for now:
  1069.  
  1070.  
  1071.  
  1072.      pwd
  1073.  
  1074.  
  1075.  
  1076.      # This shows your current working directory, where you are at the moment. You can type ls -l to list the files in this directory - you probably know this already. You may not know, though, that the prompt is stored in an environment varible - PS1. Let's change this, just because we can - this only lasts as long as your session (ie. until you exit screen or logout)
  1077.  
  1078.  
  1079.  
  1080.      export PS1="test! $PS1"
  1081.  
  1082.  
  1083.  
  1084.      # What we did there was tell our system to change the prompt to test! followed by what it was previously. You can add many useful things to your prompt, and save changes by adding the above line in your ~/.bashrc, but let's stick to screen for now.
  1085.  
  1086.  
  1087.  
  1088.      CTRL+a then n
  1089.  
  1090.      CTRL+a then p
  1091.  
  1092.  
  1093.  
  1094.      # These commands switch between tabs on screen - n for next and p for previous. These are useful for quickly switching between screen windows, without worrying about names or menus.
  1095.  
  1096.  
  1097.  
  1098.      CTRL+a then d
  1099.  
  1100.  
  1101.  
  1102.      #Now you've detached from your screen. It's still there, so we can return to it at any time we want. Sav has provided some useful scripts at this point: http://slexy.org/view/s2iSNjfnfr and http://slexy.org/view/s2ODvLiUFo, if you feel comfortable about it, adapt them to your environment and distribution.
  1103.  
  1104.  
  1105.  
  1106.      #Back on screen, here's a useful real life example: You were attached to your screen over an ssh connection, and it dropped. screen -r isn't letting you back on, because it thinks your screen is still attached.
  1107.  
  1108.  
  1109.  
  1110.      screen -x screenname
  1111.  
  1112.  
  1113.  
  1114.      #The above command will attach you back to the screen, but it won't detach it from the dead session. If your ssh crashed due to an issue with the screen, the crash might happen again! You don't want this, so let's do this one instead:
  1115.  
  1116.  
  1117.  
  1118.      screen -Dr
  1119.  
  1120.  
  1121.  
  1122.      # -D stands for DETACH and -r stands for reattach. -Dr is just a compound command that detaches it from the old session and reattaches it - think of it as screen doctor to remember it easier.
  1123.  
  1124.  
  1125.  
  1126.      CTRL+a then k
  1127.  
  1128.  
  1129.  
  1130.      # The above will KILL the screen. Use this if it crashes - it only kills the window or tab you are on, so it won't destroy your other tabs. At this point, xochipill suggests checking out ratpoison which is the screen equivilent in X windows. doxtor suggests looking at tmux as an alternative or to use alongside screen, as it offers vertical and horizontal window splitting, whereas screen only offers horizontal by default. We'll explain window splitting soon. tmux also uses CTRL+b as opposed to CTRL+a in screen, so commands do not conflict with each other. doxtor suggests that in a dual setup you use tmux locally and screen remotely, ie screen on ssh and tmux on your laptop.
  1131.  
  1132.  
  1133.  
  1134.      screen -S testsession2
  1135.  
  1136.      CTRL+a then d
  1137.  
  1138.  
  1139.  
  1140.      #Now you want to actually specify which screen we want to connect to, because we have multiple ones. You can use screen -r xxxxx.testsession with the full number from screen -ls, or just use screen -r testsession.
  1141.  
  1142.  
  1143.  
  1144.      screen -r testsession
  1145.  
  1146.  
  1147.  
  1148.      #This is especially useful if you are, for example, talking in irc and debugging a web server at the same time - you can have all your webserver stuff on the webserver screen, with tabs open for each log, and irc client with a log parser and client config in the irc screen.
  1149.  
  1150.  
  1151.  
  1152.      CTRL+a then SHIFT+s
  1153.  
  1154.  
  1155.  
  1156.      #This will split the screen, as we mentioned earlier. It will split it into two screens, horizontally.
  1157.  
  1158.  
  1159.  
  1160.      CTRL+a then TAB
  1161.  
  1162.  
  1163.  
  1164.      #You just switched to the other window in the split screen! This is a great way to multitask, maybe watch a log while you try sending emails to your webserver. Great for comparing information, too.
  1165.  
  1166.  
  1167.  
  1168.      CTRL+a then +
  1169.  
  1170.      CTRL+a then -
  1171.  
  1172.  
  1173.  
  1174.      #These commands are used to resize the current partition, making it vertically bigger or smaller. You could, for example, make a small prompt to emerge python > pythoncompilelog.log in while you tail -f pythoncompilelog.log in the larger parition!
  1175.  
  1176.  
  1177.  
  1178.      #To delete or close a screen, you just need to exit until it closes - if, for whatever reason, you can't then:
  1179.  
  1180.  
  1181.  
  1182.      CTRL+a then k
  1183.  
  1184.  
  1185.  
  1186.      #and the screen window/tab will be killed, along with any program running within it. Another useful thing is multi-user screen sessions! razor elaborated on this after the class:
  1187.  
  1188.  
  1189.  
  1190.      CTRL+a then :
  1191.  
  1192.      multiuser on
  1193.  
  1194.      CTRL+a then :
  1195.  
  1196.      acladd username
  1197.  
  1198.  
  1199.  
  1200.      #username above should be the username of the user you want to access the session.
  1201.  
  1202.  
  1203.  
  1204.      #Now you just need to ask that user to:
  1205.  
  1206.  
  1207.  
  1208.      screen -x yourusername/yourscreenname
  1209.  
  1210.  
  1211.  
  1212.      #...and they will be on the same screen! This is useful for collaborative stuff, or a quick tutorial on a console-based program.
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.      ############################################
  1219.  
  1220.       SERVICES
  1221.  
  1222.      ############################################
  1223.  
  1224.      Services are stored in /etc/init.d/ in files called runscripts, these are just shellscripts made to start, restart and stop applications. Applications run at different runlevels, anything from 0 (shutdown on nearly all Linux systems, 5 on some UNIX systems) up to 6 (reboot on Linux systems). The default runlevel is 3 on gentoo, you can type runlevel to see your current runlevel. init 0 will shutdown, as will shutdown or halt. init 6 will usually reboot.
  1225.  
  1226.  
  1227.  
  1228.      To set up services in specific runlevels, use rc-update on gentoo. rc-update add script default will add script to run on the default runlevel (3 in gentoo). init 0 is always halt and init 6 is always shutdown, generally the next init is single-user mode, the one after that is single-user mode with networking and the one after that is multi-user mode with networking. In some configurations, though not by default, one of the init levels becomes a kernel state which provides a direct command line interface to the kernel itself.
  1229.  
  1230.  
  1231.  
  1232.      rc-update add networking 5 will add networking to runlevel 5, rc-update del networking 5 will remove it from runlevel 5. If you write a script in /etc/init.d, you will need to ensure that it is executable - ie. chmod +x /etc/init.d/scriptname. To add something to the default runlevel, you can rc-update add script default (which is, in this case, 3). rc-update will refuse to change the runlevel of a script.
  1233.  
  1234.  
  1235.  
  1236.      The common /etc/init.d runscript commands are start, stop, restart and status (and often reload). There may be others too, just run /etc/init.d/scriptname for a list.
  1237.  
  1238.  
  1239.  
  1240.      ############################################
  1241.  
  1242.       NETWORK SERVICES
  1243.  
  1244.      ############################################
  1245.  
  1246.  
  1247.  
  1248.      Once your networking is up and if you have internet or LAN connectivity, you can track connections with netstat. Unfortunately, netstat is pretty illegible if you're not used to the syntax so start with netstat -pant - that will tell you the ips, pid and process name of TCP connections (TCP is the most common connection-orientated protocol used on the internet).
  1249.  
  1250.  
  1251.  
  1252.      Note that on most processes, such as apache or sshd, you can kill a connection by killing the pid of it's process, without taking out the whole daemon and killing services for the other users.
  1253.  
  1254.  
  1255.  
  1256.      To see a list of services that are listening for connections on your system, use netstat -pant | grep -i listen. Grep is a useful little program that filters text, in the most basic use it grabs lines of text containing specific patterns. The -i switch makes the grep command case insensitive.
  1257.  
  1258.  
  1259.  
  1260.      ############################################
  1261.  
  1262.       DEBUGGING SERVICES
  1263.  
  1264.      ############################################
  1265.  
  1266.      When you are debugging a service, use the 'start' function and run netstat with the grep for listen. If the service shows up, but there are still issues, the problems are likely in the server configuration. Otherwise, there may be issues with the configuration of the service itself. Using strace helps to debug services, if you look for ENOENT within the output of strace you may see permission denied or files don't exist errors that you have to correct manually. You can look at the script and edit it with emacs or vim to confirm the exact commands the script is trying to run, e.g. if cryptsetup luksOpen /dev/loop1 home is in the start function then you may want to strace -s 2000 cryptsetup luksOpen /dev/loop1 home and read it from the end back.
  1267.  
  1268.  
  1269.  
  1270.      If a file doesn't exist, it may mean that you need to symlink a library in /lib or /usr/lib. For example, if a script is looking for glibc.so.1.2 and you only have glibc.so.1.3 (locate glibc.so or find /lib -iname glibc.so) you could do something like ln -s /lib/glibc.so.6.1.3 /lib/glibc.so.6.1.2 which would create a shortcut or link to the file, directing any queries for it to your glibc.so.6.1.3.
  1271.  
  1272.  
  1273.  
  1274.      We mentioned file permissions earlier, this is a very important concept in Linux - you have three sets of permissions, the user that owns the files, the group that owns the files and everybody else. For each of these, you have read, write and execute. To change permissions on a file, you can use one of two formats - chmod u=rwx,g=rx,o=r filename or chmod 751 filename. You can see that the first one is easier to use (u stands for user, rwx for read write and execute, for example), but you really should learn the octal permissions - these are pretty simple. 4 is read, 2 is write, 1 is execute and 0 is nothing. To create the numeric permissions, just add them together - 7 for read, write and execute, 6 for read and write, 3 for write and execute for example. You could then chmod 763 filename to give owner rwx, group rw and others wx. chmod 0 with chown root:root (chown takes ownership for a file for user:group) will lock a file permenantly, or until the root user unlocks it.
  1275.  
  1276.  
  1277.  
  1278.      ############################################
  1279.  
  1280.       PERMISSIONS AND SECURITY BASICS
  1281.  
  1282.      ############################################
  1283.  
  1284.      Changing permissions to your home folder to 750, a common mask for /home/username, will ensure that nobody that is not in your group or is not you can access it (aside from root, that can access anything). One of the main reasons for not using a root account all the time, is that it ensures that you do not accidentally modify files that you would not normally have the permission to.
  1285.  
  1286.  
  1287.  
  1288.      Note that in security, more functional means less secure - being secure is not about a couple of commands, it's a whole philosophy of computer use - you must ensure that you do not enable functionality that you don't need.
  1289.  
  1290.  
  1291.  
  1292.      In your home directory, you should create the file .bashrc and add the following line to it:
  1293.  
  1294.  
  1295.  
  1296.      unset HISTFILE ; unset HISTSAVE ; unset HISTFILESIZE ; unset HISTCONTROL ; unset HISTCMD
  1297.  
  1298.  
  1299.  
  1300.      this will unset all the environment varibles related to bash history, so your commands will not be logged in .bash_history. If you want to add scripts and commands into your home directory, do the following:
  1301.  
  1302.  
  1303.  
  1304.      # ~ is simply an alias to the current logged in user's home directory
  1305.  
  1306.      mkdir ~/bin
  1307.  
  1308.      vi (or emacs) ~/.bashrc
  1309.  
  1310.      ### add the below to your .bashrc, replacing yourusernamehere with your username
  1311.  
  1312.      export PATH="$PATH:/home/yourusernamehere/bin"
  1313.  
  1314.  
  1315.  
  1316.      You will need to remember to chmod +x every script you put in ~/bin, or it will not execute. You could also chmod 750, so that owner gets rwx, group gets rx and others get nothing.
  1317.  
  1318.  
  1319.  
  1320.      To get general information about the system, try the following:
  1321.  
  1322.  
  1323.  
  1324.      # information on network interfaces and configuration
  1325.  
  1326.      ifconfig
  1327.  
  1328.      # you can find more detail in /etc/conf.d/net and /etc/conf.d/hostname
  1329.  
  1330.  
  1331.  
  1332.      # hardware devices connected to the system
  1333.  
  1334.      lspci
  1335.  
  1336.      lsusb
  1337.  
  1338.  
  1339.  
  1340.      # kernel and architecture information and version
  1341.  
  1342.      uname -a
  1343.  
  1344.  
  1345.  
  1346.      # loaded drivers. none when you don't have modules enabled in kernel
  1347.  
  1348.      lsmod
  1349.  
  1350.  
  1351.  
  1352.      # logged in users
  1353.  
  1354.      who
  1355.  
  1356.  
  1357.  
  1358.      # login history
  1359.  
  1360.      last
  1361.  
  1362.      lastlog
  1363.  
  1364.  
  1365.  
  1366.      # running processes
  1367.  
  1368.      top
  1369.  
  1370.      ps faux
  1371.  
  1372.  
  1373.  
  1374.      # ram usage
  1375.  
  1376.      free -g (in gigs)
  1377.  
  1378.      free -m (in megs)
  1379.  
  1380.  
  1381.  
  1382.      # hd usage
  1383.  
  1384.      df -h
  1385.  
  1386.  
  1387.  
  1388.      # permissions
  1389.  
  1390.      file [filename]
  1391.  
  1392.      stat [filename]
  1393.  
  1394.      ls -lash [filename]
  1395.  
  1396.  
  1397.  
  1398.      # filesizes
  1399.  
  1400.      du -sh
  1401.  
  1402.  
  1403.  
  1404.      /proc contains a lot of this information - for example, /proc/version always contains the kernel version and /proc/modules always has module information (when it's compiled within the kernel). /proc even has memory maps, open files, cpu information (/proc/cpuinfo) and ram information (/proc/meminfo) etc.
  1405.  
  1406.  
  1407.  
  1408.      If you have any problems with devices, you can type dmesg | less then scroll around with the arrow keys, and hit q to exit when you are done. This has a lot of general hardware operational information and is a great resource for debugging. You can search in less with /, just like menuconfig.
  1409.  
  1410.  
  1411.  
  1412.      One command that is often used to watch files for changes is tail -f filename. This will keep updating the file within the window, so you don't need to continually cat or less it, which is very useful in cases such as debugging a php script, as every refresh will automatically update the apache log. It's most useful when used in conjunction with software such as tmux or screen, which will be covered later.
  1413.  
  1414.  
  1415.  
  1416.      ## PROTIP ##
  1417.  
  1418.      Think about replacing su with some script to mock the luser who's trying to root your box.
  1419.  
  1420.      ## ENDPROTIP ##
  1421.  
  1422.  
  1423.  
  1424.      ## ASIDE ##
  1425.  
  1426.      Remember that Fluxbox/Gentoo/Linux are not Windows. Not everything will be in the same place, look the same or even neccessarily be compatible - you've really got to hand-pick what you install, to make sure you don't pull a load of unnecessary stuff or break your system. Just be careful, get one package at a time. Don't be afraid to remove things if they're not to your liking, there's almost always multiple ways to do things. And you will always need to configure as you go, there's few 'drop-in' programs - one of the main benifets of using a Gentoo Linux system is it's customization, which isn't hampered in the least by taking a security perspective.
  1427.  
  1428.      ## ENDASIDE ##
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.      ############################################
  1435.  
  1436.       GETTING HELP
  1437.  
  1438.      ############################################
  1439.  
  1440.      Of course, you can always ask for help with issues in #questions, but sometimes nobody knows the answer or has time to look for it, in this case you'll need to do it yourself! This is pretty easy, though, especially if you're just looking for information on a command or program.
  1441.  
  1442.  
  1443.  
  1444.      Type man command (command being the command you want help on) for a manual page, these are generally very verbose but will most likely contain what you're looking for. If you don't know exactly what command you want, try info coreutils. You can use the arrow keys to navigate topics, and press enter to select one to read more about it. If the man command takes you to the manpage for bash, try the help/info command - help read or info read, for example.
  1445.  
  1446.  
  1447.  
  1448.      A great place to find guides for most common applications online is the gentoo wiki. You can find this at http://en.gentoo-wiki.com/. Other good places are the gentoo forums at http://forums.gentoo.org/ and the Gentoo Handbook at http://www.gentoo.org/doc/en/handbook/.
  1449.  
  1450.  
  1451.  
  1452.      ############################################
  1453.  
  1454.       TROUBLESHOOTING
  1455.  
  1456.      ############################################
  1457.  
  1458.      -Unbootable disk error
  1459.  
  1460.      You need to do the grub part above, again.
  1461.  
  1462.      
  1463.  
  1464.      -Hangs on boot
  1465.  
  1466.      These are usually caused by a bad kernel, cd to /usr/src/linux and make clean then try reconfiguring the kernel, be careful so you don't miss anything
  1467.  
  1468.  
  1469.  
  1470.      -Disk errors
  1471.  
  1472.      If you get an error using cfdisk, type fdisk /dev/sda then o then w and this will wipe the disk to try again.
  1473.  
  1474.  
  1475.  
  1476.      -Errors after deleting encrypted storage
  1477.  
  1478.      If you get problems after creating and deleting a crypted store, try rebooting after you've deleted it and rc-update del home default. remember to rc-update add home default again when you're done setting it back up.
  1479.  
  1480.  
  1481.  
  1482.      -Problems with emerge
  1483.  
  1484.      If you get emerge errors, first check your make.conf to ensure it's as above. Now, try env-update && emerge -qN $PACKAGE ($PACKAGE being the package(s) you are trying to emerge, ie. emerge -qN screen). If this doesn't work, try revdep-rebuild or if the problem has perl in it, try perl-cleaner reallyall. If you get a python problem, try python-updater and to ensure GCC is working use gcc-config -l (if you get an error about not being able to build executables, GCC needs fixed - try gcc-config 1 && emerge -qN gcc after fixing make.conf). Another thing to try is FEATURES="-sandbox -usersandbox" emerge -q sandbox then attempting the emerge again, if this works make sure to echo "sys-apps/sandbox -sandbox -usersandbox" >> /etc/portage/package.use to ensure you don't break portage on upgrading sandbox.
  1485.  
  1486.  
  1487.  
  1488.      -Problem emerging cryptsetup
  1489.  
  1490.      If you get a package mask (static-libs) error while doing emerge -q cryptsetup, try the following commands:
  1491.  
  1492.      mkdir /etc/portage
  1493.  
  1494.      echo "sys-fs/cryptsetup static-libs" >> /etc/portage/package.use
  1495.  
  1496.      env-update && emerge -q cryptsetup
  1497.  
  1498.  
  1499.  
  1500.  -General problems with emerging mesa
  1501.  
  1502.  Unfortunately, it seems that the mesa package is not happy with -fstack-protector-all. Although we do NOT reccomend this (for security reasons) it is possible to install mesa by removing this from your CFLAGs in make.conf and
  1503.  
  1504.  recompiling the system. We do NOT recommend this, please wait for a better fix.
  1505.  
  1506.  
  1507.  
  1508.     -Problem emerging mesa on vmware
  1509.  
  1510.       Check your build log (emerge should tell you where it is) and see if it gives you an error about XML parser
  1511.  
  1512.       if so you may need to emerge XML_Parser