
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Welcome to the rubber-ducky
Ruby library! This library provides an easy-to-use interface for encoding and decoding Rubber Ducky scripts into binary files and vice versa. Whether you're a beginner or a seasoned developer, this README will guide you through everything you need to know to get started and make the most of this library.
To install the rubber-ducky
gem, simply add it to your Gemfile or install it directly using gem
:
gem install rubber-ducky
Alternatively, you can include it in your Gemfile
:
gem 'rubber-ducky'
Then, run bundle install
to install the gem.
Let's start with the basics. The rubber-ducky
library allows you to encode and decode Rubber Ducky scripts. Here’s how to use it:
To encode a Rubber Ducky script, you'll first need a script written in a plain text file. Let's assume you have a file named payload.txt
with the following content:
DELAY 500
GUI r
DELAY 500
STRING cmd
CTRL-SHIFT ENTER
DELAY 1000
ALT y
DELAY 500
STRING netsh advfirewall set allprofiles state off
ENTER
To encode this script into a binary file, use the following code:
require 'rubber-ducky'
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'us')
This will generate a binary file named inject.bin
that can be used with a Rubber Ducky USB device.
Decoding a binary file back to its script form is just as easy. Assuming you have a binary file named inject.bin
, you can decode it like this:
require 'rubber-ducky'
decoded_script = Rubber::Ducky.decode('inject.bin', output: 'payload-decode.txt', language: 'us')
puts "Decoded content:"
puts decoded_script
This will output the decoded script to the console and save it to payload-decode.txt
.
Now that you're familiar with the basics, let's dive into some advanced features.
You can customize the encoding and decoding processes by directly manipulating the content before encoding or after decoding. For example:
require 'rubber-ducky'
# Read the script from a file
script = File.read('payload.txt')
# Modify the script if needed
script.gsub!('500', '1000') # Change all delays from 500ms to 1000ms
# Encode the modified script
Rubber::Ducky.encode(script, output: 'inject.bin', language: 'us')
# Decode it back to verify the changes
decoded_script = Rubber::Ducky.decode('inject.bin')
puts decoded_script
The library supports multiple keyboard layouts. You can specify the language using the language
option. For example, to encode a script using the German keyboard layout:
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'de')
Similarly, to decode a file encoded with the German layout:
decoded_script = Rubber::Ducky.decode('inject.bin', language: 'de')
For advanced users, here are some tips to make the most of the rubber-ducky
library.
You can easily integrate this library with other Ruby tools and frameworks. For example, you can use it in a Rails application to generate payloads on the fly:
class PayloadsController < ApplicationController
def create
script = params[:script]
file_path = Rails.root.join('tmp', 'inject.bin')
Rubber::Ducky.encode(script, output: file_path, language: 'us')
send_file file_path, type: 'application/octet-stream', filename: 'inject.bin'
end
end
The library is designed to be robust, but you should still handle potential errors gracefully:
begin
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'us')
rescue StandardError => e
puts "An error occurred during encoding: #{e.message}"
end
We welcome contributions! If you'd like to contribute to this project, please fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Whether you're automating tasks with a Rubber Ducky or exploring new ways to interact with devices, the rubber-ducky
Ruby library offers a powerful and flexible toolset to get the job done. Happy coding!
FAQs
Unknown package
We found that rubber-ducky demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.