Presentation nix


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Presentation nix

  1. 1. SSH Tricks and More! Presented by Kyle Young
  2. 2. Who am I?• Just another computer technician• Obtaining my macro degree in network administration from GRCC• Planning on getting a Bachelors degree in Digital Forensics at FSU• Been tinkering with computers since I was in middle school• Became obsessed with Information Security in 2005• Owner/Hoster of• Administrator on HITB forums
  3. 3. Read this book if you want to learn more about SSH!SSH, The Secure Shell: The DefinitiveGuide, 2nd EditionBy Daniel J. Barrett, Richard E. Silverman,Robert G. ByrnesPublisher: OReilly MediaReleased: May 2005Pages: 668
  5. 5. Why do a presentation on SSH tricks?• SSH is one of my favorite protocols• There have been plenty of articles and blog posts on the subject – I thought it was time to kind of aggregate these and add some of my own tips/tricks
  6. 6. What is SSH?• Is it a shell? … No• Is it a solution to all of your security problems? … No“Secure Shell or SSH is a network protocol that allows data to be exchanged using a secure channel between two networked devices.” -
  7. 7. SSH History• SSH v1.X - Invented by Tatu Ylönen in 1995• Created due to a password sniffing attack that took place at Helsinki University of Technology• Created as a secure replacement for telnet, rlogin and rsh protocols
  8. 8. SSH and You!• If you work in the information technology realm, there’s a good chance you have used SSH before.• The SSH Client is natively available on practically all Non-Windows Operating Systems• Can be more quick and dirty than Remote Desktop• Easier to use on a phone than Remote Desktop (You may want to check out ‘mosh’ )
  9. 9. What can I use SSH for?• For login to a shell on a remote host• For executing a single command on a remote host (replacing rsh)• Secure file transfer• For forwarding or Tunneling• Forwarding X from remote hosts• The list goes on... e
  10. 10. SSH and Cyber Espionage• Duqu Worm – (Nov 2011) Contained instructions to exploit a zero day vulnerability in OpenSSH 4.3 on CentOS systems – After compromising the system the worm then updated OpenSSH to version 5.8
  11. 11. Speaking of SCADA/SSH...“Another day, another SCADA threat: ICS-CERT isnow warning utilities and other criticalinfrastructure providers about potential brute-force attacks against control systems with SSHcommand-line access. “- Kelly Jackson Higgins ( 06, 2012
  12. 12. Basic SSH Usage
  13. 13. Insecurity Issues With Default Client SettingsMake sure your clients (and servers) are strictly using version 2 Or they may be vulnerable to version downgrade attacks! You can also edit your ssh_config and change the directive : Protocol 2 
  14. 14. Downgrade attacks on SSH ClientsDowngrade attacks can be performed with ettercap-ng and ettercap-filters!  Image From
  15. 15. Connecting for the first time to an SSH Server: Do you know it’s safe?If you’re very paranoid, you’ll want to verify the RSA fingerprint and randomart image with what fingerprint your given when connecting. To do so: On the server side you’ll have (usually requiring physical access to the Machine) You would need to do this:sudo ssh-keygen -lvf /etc/ssh/ssh_host_rsa_key.pubThen on your client side you want to edit your ssh_config file and set this option:VisualHostKey yes
  16. 16. Connecting for the first time to anSSH Server: Do you know it’s safe? One issue with this: “Obviously you need a secure method of getting verified copies of the fingerprint and randomart images for the computers you want to log into. ” - Carla  Schroder
  17. 17. One other thing.. Oh yeah Kippo can be ugly..An attacker can capture your SSHv2 credentials using Kippo:•To do so an attacker needs to be in your local area network or spoofing the IP address or domain name of the SSH server host that the victim is trying to connect to. •Setup Kippo to listen on the appropriate port•If needed perform an ARP poisoning attack on the victim.•Once the victim tries to connect they would most likelyget a mismatching fingerprint. However, with putty, an ignorant or hasty victim could simply click “YES”.
  18. 18. OK I’m connected…am I still safe? Not necessarily  - Some versions of the openssh- server  daemon will handle  password authentication in clear  text in memory!  Proof of concept:   #Tested on SSH-2.0-OpenSSH_4.7p1  Debian-8ubuntu1.2  #Tested on SSH-2.0-OpenSSH_5.1p1  Debian-5ubuntu1  #Tested on OpenSSH 5.2 (protocol 2.0)  Fedora 11 Need to find the source on this  one! 
  19. 19. OK I’m connected…am I still safe?Watch out on your client side: man’s SSH keylogger! 
  20. 20. Locking Down The Server Side: sshd_config is your friend!•This may be debatable, but change your ssh server’s listening port to something different than port 22.• Again.. Make sure your ssh server is strictly using Protocol Version 2•Do not permit root login!•Permit/Deny only specific users or groups! (AllowUsers/AllowGroupsDirective OR DenyUsers/DenyGroups)
  21. 21. Oh yeah..a quick note on changing the default port for ssh
  22. 22. Oh yeah..a quick note on changing the default port for ssh
  23. 23. Locking Down The Server Side: sshd_config is your friend!•Disable PasswordAuthentication and authenticate only using keys•Configure an Idle Log out time period (ClientAliveInterval XXX )•Limit what interface/addresses SSHD binds to•Limit the amount of authentication tries (MaxAuthTries )
  24. 24. Locking Down The Server Side: sshd_config is your friend!•Change the login grace time (LoginGraceTime)•Oh yeah… disable empty passwords (Duh..) (PermitEmptyPasswords no)
  25. 25. Locking Down The Server Side: Programs to help you lock down your server•If applicable use iptables (or pf) to permit/deny specific IP addresses/rangesList of programs to help ward off dictionary attacks/brute force attacks on•Setup port-knocking!
  26. 26. Quick tips for speeding up SSHD login sshd_config is your friend!•Disable server side DNS look-ups if you don’t need it. (UseDNS No)If you’re not using PAM with SSH then disable PAM(UsePAM No)
  27. 27. Client side configuration tips ssh_config is your friend!Are you sick of constantly typing in your passwords (if you’re using passwords) when doing additional connections when you’ve already authenticated to your ssh server? Solution: Add this to your ssh_config file Host *ControlPath ~/.ssh/master-%r@%h:%pControlMaster auto
  28. 28. Client side configuration tips ssh_config is your friend!Save yourself some keystrokes!ssh –C –D 1234 -p 5432 Edit your ssh_config file to something like this:Host example HostName   User user Port 5432DynamicForward 1234 Compression YesNow you only need to type:ssh example
  29. 29. Client side configuration tips ssh_config is your friend!Are there any options to check for DNS spoofing? YES! CheckHostIP YesThis will force ssh to do an additional check in the known_hosts file for the IP address of the server. 
  30. 30. For more information on configuring sshd_config and ssh_config, please see: man sshd_config && man ssh_config
  31. 31. Now for those beautiful client-sided one liners…(top 10 one liners from
  32. 32. Client-sided one liners…(top 10 one liners from
  33. 33. Client-sided one liners…(top 10 one liners from
  34. 34. Client-sided one liners…(more awesome one liners from
  35. 35. Client-sided one liners…(more awesome one liners from
  36. 36. For more awesome one-liners from
  37. 37. More awesome one-liners:’t want to expose remote desktop via your firewall? You can still use it through ssh!:ssh –L 3389: Put the ssh client in a very verbose mode for troubleshooting/debugging:ssh –vvv
  38. 38. More awesome one-liners:,1Pipe webcam over ssh:
  39. 39. Client-sided one liners: Fun with the ‘-t’ optionAny programs that need a pseudo terminal screen to work and you need run quickly, use -t.Examples:ssh –t “python”ssh –t “irb”ssh –t “ssh”ssh –t “msfconsole” ssh –t “screen”ssh  -t “vi”
  40. 40. Client-sided one liners: Fun with reverse connectionsDon’t have metasploit or any fancy info-sec security tools on your device that is connected to a LAN, but this device still has an SSH client on it? NO PROBLEM!Target host: port: 445Payload port: 4444ssh –t –R –R “msfconsole”Then through metasploit  on your remote host you would point your attacks towards your loopback interface 
  41. 41. Client-sided one liners (Poor man’s VPN/proxy)This will bind a SOCKS server to port 9050 on the interface 
  42. 42. Client-sided one liners (Poor man’s VPN/proxy)OK big deal.. I know that.. What’s special about it? 
  43. 43. Client-sided one liners (Poor man’s VPN/proxy)What this means: •You can now tunnel traffic securely between you the client, and• If’s subnet is, you can now access resources in that subnet via your tunnel, hence why this is a poorman’s VPN.•You can use programs like proxychains in tandem with SOCKS•NOTE:’s hosts file (/etc/hosts) does affect the DNS name resolution of the SOCKS client  
  44. 44. Client-sided one liners (Poor man’s VPN/proxy)Programs that play nicely with proxychains: rdesktopnetcatsocatnmap hpingtelnetopenvasnessushydrawgetsshmetasploit (though not needed) (set Proxies socks5:localhost:1234) ncrack...(The list goes on)Almost any application that works on *nix and relies on TCP/IP
  45. 45. Ways of setting up sshd the quick and dirty way…Scenario 1:Are you doing a pentest and you’re able to find a router that is compatible with openwrt  or dd-wrt? Upload it! Most versions of openwrt and dd-wrt support SSHDScenario 2:You’ve popped a shell on a Windows box and you’d like to setup an SSHD server:Copssh_3.1.4_Installer.exe /S Copssadm --command activeuser –user USERNAME –shell /bin/bash 
  46. 46. Ways of setting up sshd the quick and dirty way…Meterpreter from the metasploit project now has a meterpreter script that can deploy an openssh server on Windows victims.  (I must admit, the few times I’ve tried it, it has never worked for me!) 
  47. 47. SSH and Window$SSH Clients on Windows:Putty, plink, psftp, ssh (cygwin) (there are a bunch.. one of the best guides for installing Cygwin w/ an openssh server on Windows: Follow the steps very closely! Minimal/Easy Install options of cygwin with sshd: X11 forwarding over SSH, Install Xming and use putty: 
  48. 48. Programming/Automating SSHExamples of languages that you can use for automating SSH:
  49. 49. Programming/Automating SSHPython Example: Very good guide on paramiko:
  50. 50. SSH and IPV6Very good guide for getting around with IPv6 and show examples of SSH usage: to check:•Use ping6 to ping at least your lookback interface ::1•Use ping6 to ping ipv6 domain names: (i.e.•Make sure your IPV6 server is setup to listen on an IPV6 address (NOTE: in IPV6 is ::: )Simple example using ssh and ipv6:ssh user@2001:4860:800a::93
  51. 51. Live Demo: SSH/Miredo/IPV6 Thanks Mubix! ( )
  52. 52. ?Questions?
  53. 53. FIN!Postscript: man ssh