You are previewing Wicked Cool Ruby Scripts.
O'Reilly logo
Wicked Cool Ruby Scripts

Book Description

Wicked Cool Ruby Scripts is a compendium of scripts that will make your life easier by saving you time and solving problems. If you find yourself wasting effort and time on a task a trained monkey could do, it's time for Ruby to come to the rescue.

Wicked Cool Ruby Scripts provides carefully selected Ruby scripts that are immediately useful. Learn how to streamline administrative tasks like renaming files, disabling processes, and changing permissions. After you get your feet wet creating basic scripts, author Steve Pugh will show you how to create powerful Web crawlers, security scripts, full-fledged libraries and applications, and much more. With each script you'll get the raw code followed by an explanation of how it really works, as well as instructions for how to run the script and suggestions for customizing it. Wicked Cool Ruby Scripts will save you from the tedium of repetitive tasks and give you back the time it would take to write scripts from scratch.

Table of Contents

  1. Wicked Cool Ruby Scripts
    1. FOREWORD
    2. ACKNOWLEDGMENTS
    3. INTRODUCTION
      1. Wicked Cool Ruby Scripts
      2. You Need Ruby Basics
      3. Documentation
      4. Organization and Approach
      5. The Website
    4. 1. GENERAL PURPOSE UTILITIES
      1. Check for Changed Files
        1. Check for Changed Files
          1. changedFiles.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      2. Encrypt a File
        1. Encrypt a File
          1. encrypt.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      3. Decrypt a File
        1. Decrypt a File
          1. decrypt.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      4. File Splitting
        1. File Splitting
          1. fileSplit.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. File Joining
        1. File Joining
          1. fileJoin.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      6. Windows Process Viewer
        1. Windows Process Viewer
          1. listWin Processes.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      7. File Compressor
        1. File Compressor
          1. compress.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      8. File Decompression
        1. File Decompression
          1. decompress.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      9. Mortgage Calculator
        1. Mortgage Calculator
          1. mortgageCalc.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
    5. 2. WEBSITE SCRIPTING
      1. Web Page Link Validator
        1. Web Page Link Validator
          1. linkValidator.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      2. Orphan File Checker
        1. Orphan File Checker
          1. orphanCheck.rb
        2. The Code
        3. Running the Script
        4. The Results
        5. How It Works
      3. Form Generator
        1. Form Generator
          1. formGenerator.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      4. RSS Parsing
        1. RSS Parsing
          1. rssParser.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. Stock Exchange Grep
        1. Stock Exchange Grep
          1. stockGrep.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      6. IP Address Generation
        1. IP Address Generation
          1. ipAdderGen.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      7. Subnet Calculator
        1. Subnet Calculator
          1. subnetCalc.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
    6. 3. LI(U)NIX SYSTEM ADMINISTRATION
      1. Fixing Bad Filenames
        1. Fixing Bad Filenames
          1. fixFilename.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      2. Adding a User
        1. Adding a User
          1. addUser.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      3. Modifying a User
        1. Modifying a User
          1. modUser.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      4. Killing a Stuck Process
        1. Killing a Stuck Process
          1. killProcess.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      5. Validating Symlinks
        1. Validating Symlinks
          1. symlinkCheck.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
    7. 4. PICTURE UTILITIES
      1. Mass Editing
        1. Mass Editing
          1. massEdit.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      2. Image Information Extraction
        1. Image Information Extraction
          1. imageInfo.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      3. Creating a Thumbnail
        1. Creating a Thumbnail
          1. thumbnail.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      4. Resize a Picture
        1. Resize a Picture
          1. resizePhoto.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. Adding a Watermark to Pictures
        1. Adding a Watermark to Pictures
          1. watermark.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      6. Convert to Black and White
        1. Convert to Black and White
          1. bwPhoto.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      7. Creating a Photo Gallery
        1. Creating a Photo Gallery
          1. createGallery.rb
        2. The Code
        3. Running the Code
        4. Results
        5. How It Works
        6. Hacking the Script
    8. 5. GAMES AND LEARNING TOOLS
      1. Sudoku Solver
        1. Sudoku Solver
          1. sudoku.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      2. Flash Cards
        1. Flash Cards
          1. flashCards.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      3. Number-Guessing Game
        1. Number-Guessing Game
          1. guessingGame.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      4. Rock, Paper, Scissors
        1. Rock, Paper, Scissors
          1. rps.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. Word Scramble
        1. Word Scramble
          1. wordScramble.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      6. Hangman
        1. Hangman
          1. hangman.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      7. Pig
        1. Pig
          1. pig.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
    9. 6. STRING UTILITIES
      1. PDF Generator
        1. PDF Generator
          1. pdfGen.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      2. Word Frequency
        1. Word Frequency
          1. wordFreq.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      3. Comma-Separated Value Parser
        1. Comma-Separated Value Parser
          1. csv.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      4. CSV to XML
        1. CSV to XML
          1. csvToXML.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. Ruby Grep
        1. Ruby Grep
          1. rubyGrep.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      6. Password Check
        1. Password Check
          1. password.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
    10. 7. SERVERS AND SCRAPERS
      1. Define
        1. Define
          1. define.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      2. Automated SMS
        1. Automated SMS
          1. sms.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      3. Link Scrape
        1. Link Scrape
          1. linkScrape.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      4. Image Scrape
        1. Image Scrape
          1. imageScrape.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
        6. Hacking the Script
      5. Scraper
        1. Scraper
          1. scrape.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      6. Encrypted Client
        1. Encrypted Client
          1. RSA_client.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      7. Encrypted Server
        1. Encrypted Server
          1. RSA_server.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
    11. 8. ARGUMENTS AND DOCUMENTATION
      1. File Security
        1. File Security
          1. fileSecurity.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      2. Web Scraper
        1. Web Scraper
          1. webScraper.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      3. Photo Utilities
        1. Photo Utilities
          1. photoUtility.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      4. Conclusion
    12. 9. SORTING ALGORITHMS
      1. Bubble Sort
        1. Bubble Sort
          1. bubbleSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      2. Selection Sort
        1. Selection Sort
          1. selectionSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      3. Shell Sort
        1. Shell Sort
          1. shellSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      4. Merge Sort
        1. Merge Sort
          1. mergeSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      5. Heap Sort
        1. Heap Sort
          1. heapSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      6. Quick Sort
        1. Quick Sort
          1. quickSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      7. Shear Sort
        1. Shear Sort
          1. shearSort.rb
        2. The Code
        3. Running the Code
        4. The Results
        5. How It Works
      8. A Note About Efficiencies
    13. 10. WRITING A METASPLOIT 3.1 MODULE WITH RUBY
      1. Introduction to Metasploit
      2. Installation
      3. Writing a Module
      4. Building the Exploit
      5. Watching in Real Time
      6. Explanation of Metasploit Module Shell
      7. Finding the Payload Space
    14. A. AFTERWORD
    15. About the Author
    16. COLOPHON