rubber-ducky 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/gem-push.yml +48 -0
- data/.github/workflows/ruby.yml +34 -0
- data/.gitignore +55 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +40 -0
- data/CODE_OF_CONDUCT.md +39 -0
- data/CONTRIBUTING.md +47 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +177 -0
- data/Rakefile +37 -0
- data/examples/example1.rb +10 -0
- data/lib/languages/be.json +169 -0
- data/lib/languages/br.json +169 -0
- data/lib/languages/ca-fr.json +170 -0
- data/lib/languages/ca.json +169 -0
- data/lib/languages/ch.json +169 -0
- data/lib/languages/cz.json +169 -0
- data/lib/languages/de.json +169 -0
- data/lib/languages/dk.json +167 -0
- data/lib/languages/es-la.json +176 -0
- data/lib/languages/es.json +169 -0
- data/lib/languages/fi.json +169 -0
- data/lib/languages/fr.json +169 -0
- data/lib/languages/gb.json +169 -0
- data/lib/languages/hr.json +169 -0
- data/lib/languages/it.json +169 -0
- data/lib/languages/mx.json +177 -0
- data/lib/languages/no.json +169 -0
- data/lib/languages/pt.json +169 -0
- data/lib/languages/se.json +169 -0
- data/lib/languages/si.json +169 -0
- data/lib/languages/sk.json +169 -0
- data/lib/languages/us.json +170 -0
- data/lib/rubber-ducky/common.rb +36 -0
- data/lib/rubber-ducky/decoder.rb +55 -0
- data/lib/rubber-ducky/encoder.rb +92 -0
- data/lib/rubber-ducky/version.rb +5 -0
- data/lib/rubber-ducky.rb +28 -0
- data/rubber-ducky.gemspec +32 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 22874993488bcf36f82ffa62a02c4b8a21b5f614796e90cad6cb31595105a3b4
|
4
|
+
data.tar.gz: bb0393a3dcc732e203cafe4ca3455c462ebe287291cf7d70265b56c7736cbfb8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ffdad9467899f70fbd6848dc2e5df3c76850fcfa1f09e2abafd9a77d1e34feb5e74719f83a029b2475ab4d3a19cf345c565c418e20b79fa1dc09f9fdd89eb139
|
7
|
+
data.tar.gz: ec3487204efb29e3a461d7b85f06b0d840700ac4ee49bd0042dcabe9827b29eebee92cb871c5c6234d3ec75393f715a75ffa0c549674c6a79edf9b23768372b9
|
@@ -0,0 +1,48 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "main" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "main" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Set up Ruby 2.6
|
20
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
21
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
22
|
+
# uses: ruby/setup-ruby@v1
|
23
|
+
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
|
24
|
+
with:
|
25
|
+
ruby-version: 2.6.10
|
26
|
+
|
27
|
+
- name: Publish to GPR
|
28
|
+
run: |
|
29
|
+
mkdir -p $HOME/.gem
|
30
|
+
touch $HOME/.gem/credentials
|
31
|
+
chmod 0600 $HOME/.gem/credentials
|
32
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
33
|
+
gem build *.gemspec
|
34
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
35
|
+
env:
|
36
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
37
|
+
OWNER: ${{ github.repository_owner }}
|
38
|
+
|
39
|
+
- name: Publish to RubyGems
|
40
|
+
run: |
|
41
|
+
mkdir -p $HOME/.gem
|
42
|
+
touch $HOME/.gem/credentials
|
43
|
+
chmod 0600 $HOME/.gem/credentials
|
44
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
45
|
+
gem build *.gemspec
|
46
|
+
gem push *.gem
|
47
|
+
env:
|
48
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: Build + Publish
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-22.04
|
12
|
+
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
ruby-version: ['2.7.8', '3.2.2']
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
24
|
+
|
25
|
+
- name: Install dependencies
|
26
|
+
run: bundle install
|
27
|
+
|
28
|
+
- name: Run tests
|
29
|
+
run: bundle exec rspec
|
30
|
+
|
31
|
+
- name: Build and publish
|
32
|
+
run: gem build rubber-ducky.gemspec && gem push rubber-ducky-*.gem
|
33
|
+
env:
|
34
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Ignore bundler config
|
2
|
+
/.bundle
|
3
|
+
|
4
|
+
# Ignore the installed gems
|
5
|
+
/vendor/bundle
|
6
|
+
|
7
|
+
# Ignore the Gemfile.lock, since it's usually generated and not necessary to track
|
8
|
+
/Gemfile.lock
|
9
|
+
|
10
|
+
# Ignore log files and temp files
|
11
|
+
/log/*
|
12
|
+
/tmp/*
|
13
|
+
!/log/.keep
|
14
|
+
|
15
|
+
# Ignore compiled output
|
16
|
+
/*.o
|
17
|
+
/*.so
|
18
|
+
/*.log
|
19
|
+
/*.out
|
20
|
+
/*.bin
|
21
|
+
|
22
|
+
# Ignore test coverage files
|
23
|
+
/coverage/
|
24
|
+
|
25
|
+
# Ignore spec and test files
|
26
|
+
/spec/tmp/
|
27
|
+
/spec/*.bin
|
28
|
+
|
29
|
+
# Ignore IDE files
|
30
|
+
.idea/
|
31
|
+
.vscode/
|
32
|
+
|
33
|
+
# Ignore system files
|
34
|
+
.DS_Store
|
35
|
+
|
36
|
+
# Ignore Ruby-specific files
|
37
|
+
.ruby-version
|
38
|
+
.ruby-gemset
|
39
|
+
|
40
|
+
# Ignore Rake files
|
41
|
+
/rdoc/
|
42
|
+
/.rake_tasks~
|
43
|
+
|
44
|
+
# Ignore the gem build artifacts
|
45
|
+
/pkg/
|
46
|
+
rubber-ducky-*.gem
|
47
|
+
|
48
|
+
# Ignore byebug history file
|
49
|
+
.byebug_history
|
50
|
+
|
51
|
+
# Ignore dotenv environment variable files
|
52
|
+
.env
|
53
|
+
|
54
|
+
# Ignore node_modules if any JavaScript is used
|
55
|
+
/node_modules/
|
data/.travis.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 3.0.0
|
4
|
+
- 2.7.2
|
5
|
+
|
6
|
+
# Run the script only on the default branch (usually master/main)
|
7
|
+
branches:
|
8
|
+
only:
|
9
|
+
- main
|
10
|
+
|
11
|
+
# Install dependencies
|
12
|
+
before_install:
|
13
|
+
- gem install bundler
|
14
|
+
|
15
|
+
# Run the script
|
16
|
+
script:
|
17
|
+
- bundle exec rspec
|
18
|
+
|
19
|
+
# Cache bundler dependencies to speed up future builds
|
20
|
+
cache: bundler
|
21
|
+
|
22
|
+
# Notifications (optional)
|
23
|
+
notifications:
|
24
|
+
email:
|
25
|
+
recipients:
|
26
|
+
- qppn@hotmail.com
|
27
|
+
on_success: change
|
28
|
+
on_failure: always
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Initial release of the `rubber-ducky` gem.
|
12
|
+
- Support for encoding Rubber Ducky scripts into binary files.
|
13
|
+
- Support for decoding binary files back into Rubber Ducky scripts.
|
14
|
+
- Multi-language support for different keyboard layouts.
|
15
|
+
- Customizable encoding and decoding options.
|
16
|
+
- Basic error handling and validation for input files.
|
17
|
+
- Integration with Ruby projects and applications.
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- Updated documentation with detailed usage examples for beginners and professionals.
|
21
|
+
- Improved error messages for common issues during encoding/decoding.
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Resolved issues with decoding specific characters in non-English keyboard layouts.
|
25
|
+
|
26
|
+
## [1.0] - 2024-08-16
|
27
|
+
### Added
|
28
|
+
- Basic encoding and decoding functionalities.
|
29
|
+
- Support for multiple keyboard layouts (languages).
|
30
|
+
- Comprehensive unit tests for core functionality.
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
- Initial creation of the project structure and essential files.
|
34
|
+
|
35
|
+
### Fixed
|
36
|
+
- Initial bug fixes during development and testing phase.
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
For more details on each change, please refer to the commit history or the project's GitHub repository.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
22
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
23
|
+
* Public or private harassment
|
24
|
+
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
25
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
26
|
+
|
27
|
+
## Enforcement Responsibilities
|
28
|
+
|
29
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
32
|
+
|
33
|
+
## Scope
|
34
|
+
|
35
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
36
|
+
|
37
|
+
## Enforcement
|
38
|
+
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Contributing to Rubber Ducky Ruby Library
|
2
|
+
|
3
|
+
First off, thank you for considering contributing to the Rubber Ducky Ruby Library! Your contributions are highly appreciated.
|
4
|
+
|
5
|
+
## How to Contribute
|
6
|
+
|
7
|
+
### Reporting Bugs
|
8
|
+
|
9
|
+
If you find a bug, please create an issue on GitHub. Provide as much detail as possible, including steps to reproduce the issue, and if possible, a minimal code example demonstrating the problem.
|
10
|
+
|
11
|
+
### Suggesting Features
|
12
|
+
|
13
|
+
We are open to new ideas! If you have a feature request, please create an issue on GitHub with a detailed description of the feature, how it would work, and why it would be beneficial.
|
14
|
+
|
15
|
+
### Submitting Changes
|
16
|
+
|
17
|
+
1. **Fork the Repository**: Create a personal fork of the repository on GitHub.
|
18
|
+
|
19
|
+
2. **Create a Branch**: Create a new branch on your fork to work on your changes. Use a descriptive name for your branch (e.g., `fix-typo-in-readme`, `add-new-feature`).
|
20
|
+
|
21
|
+
3. **Make Changes**: Make your changes to the codebase. Ensure that your code follows the existing coding standards and passes all tests.
|
22
|
+
|
23
|
+
4. **Run Tests**: Before submitting your changes, make sure all tests pass. You can run the tests using `bundle exec rspec`.
|
24
|
+
|
25
|
+
5. **Commit Your Changes**: Write clear, descriptive commit messages. If your change fixes an issue, include `Fixes #issue_number` in your commit message.
|
26
|
+
|
27
|
+
6. **Push Your Changes**: Push your changes to your forked repository.
|
28
|
+
|
29
|
+
7. **Create a Pull Request**: Go to the original repository and create a pull request. Describe your changes in detail, and reference any relevant issues.
|
30
|
+
|
31
|
+
### Code Style
|
32
|
+
|
33
|
+
Please follow the coding style used in the project. We recommend using RuboCop to ensure that your code meets the Ruby style guide.
|
34
|
+
|
35
|
+
### Testing
|
36
|
+
|
37
|
+
Make sure that your changes are covered by tests. If you're adding a new feature, add new tests. If you're fixing a bug, add a test that verifies the fix.
|
38
|
+
|
39
|
+
### Documentation
|
40
|
+
|
41
|
+
Ensure that your changes are documented. This includes updating the README if necessary, as well as any other relevant documentation files.
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Please note that this project adheres to a [Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
|
46
|
+
|
47
|
+
Thank you for your contributions!
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 MAVEN
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rubber-ducky.svg)](https://badge.fury.io/rb/rubber-ducky)
|
3
|
+
[![License: MIT](https://cdn.prod.website-files.com/5e0f1144930a8bc8aace526c/65dd9eb5aaca434fac4f1c34_License-MIT-blue.svg)](/LICENSE)
|
4
|
+
|
5
|
+
|
6
|
+
# [join to our telegram for more Rubber Ducky scripts]('https://t.me/@DuckyScript1') <a href="https://t.me/@DuckyScript1" target="blank"><img align="center" src="https://raw.githubusercontent.com/AliSawari/github-profile-readme-generator/master/src/images/icons/Social/telegram.svg" alt="Telegram: maxbarsukov" height="25" width="30" /></a>
|
7
|
+
# Rubber Ducky Ruby Library
|
8
|
+
|
9
|
+
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.
|
10
|
+
|
11
|
+
## Table of Contents
|
12
|
+
|
13
|
+
- [Installation](#installation)
|
14
|
+
- [Basic Usage](#basic-usage)
|
15
|
+
- [Encoding a Script](#encoding-a-script)
|
16
|
+
- [Decoding a Binary File](#decoding-a-binary-file)
|
17
|
+
- [Advanced Usage](#advanced-usage)
|
18
|
+
- [Customizing Encoding and Decoding](#customizing-encoding-and-decoding)
|
19
|
+
- [Working with Different Languages](#working-with-different-languages)
|
20
|
+
- [Professional Tips and Tricks](#professional-tips-and-tricks)
|
21
|
+
- [Integrating with Other Tools](#integrating-with-other-tools)
|
22
|
+
- [Error Handling](#error-handling)
|
23
|
+
- [Best Practices](#best-practices)
|
24
|
+
- [Contributing](#contributing)
|
25
|
+
- [License](#license)
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
To install the `rubber-ducky` gem, simply add it to your Gemfile or install it directly using `gem`:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
gem install rubber-ducky
|
33
|
+
```
|
34
|
+
|
35
|
+
Alternatively, you can include it in your `Gemfile`:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
gem 'rubber-ducky'
|
39
|
+
```
|
40
|
+
|
41
|
+
Then, run `bundle install` to install the gem.
|
42
|
+
|
43
|
+
## Basic Usage
|
44
|
+
|
45
|
+
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:
|
46
|
+
|
47
|
+
### Encoding a Script
|
48
|
+
|
49
|
+
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:
|
50
|
+
|
51
|
+
```text
|
52
|
+
DELAY 500
|
53
|
+
GUI r
|
54
|
+
DELAY 500
|
55
|
+
STRING cmd
|
56
|
+
CTRL-SHIFT ENTER
|
57
|
+
DELAY 1000
|
58
|
+
ALT y
|
59
|
+
DELAY 500
|
60
|
+
STRING netsh advfirewall set allprofiles state off
|
61
|
+
ENTER
|
62
|
+
```
|
63
|
+
|
64
|
+
To encode this script into a binary file, use the following code:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
require 'rubber-ducky'
|
68
|
+
|
69
|
+
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'us')
|
70
|
+
```
|
71
|
+
|
72
|
+
This will generate a binary file named `inject.bin` that can be used with a Rubber Ducky USB device.
|
73
|
+
|
74
|
+
### Decoding a Binary File
|
75
|
+
|
76
|
+
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:
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
require 'rubber-ducky'
|
80
|
+
|
81
|
+
decoded_script = Rubber::Ducky.decode('inject.bin', output: 'payload-decode.txt', language: 'us')
|
82
|
+
puts "Decoded content:"
|
83
|
+
puts decoded_script
|
84
|
+
```
|
85
|
+
|
86
|
+
This will output the decoded script to the console and save it to `payload-decode.txt`.
|
87
|
+
|
88
|
+
## Advanced Usage
|
89
|
+
|
90
|
+
Now that you're familiar with the basics, let's dive into some advanced features.
|
91
|
+
|
92
|
+
### Customizing Encoding and Decoding
|
93
|
+
|
94
|
+
You can customize the encoding and decoding processes by directly manipulating the content before encoding or after decoding. For example:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
require 'rubber-ducky'
|
98
|
+
|
99
|
+
# Read the script from a file
|
100
|
+
script = File.read('payload.txt')
|
101
|
+
|
102
|
+
# Modify the script if needed
|
103
|
+
script.gsub!('500', '1000') # Change all delays from 500ms to 1000ms
|
104
|
+
|
105
|
+
# Encode the modified script
|
106
|
+
Rubber::Ducky.encode(script, output: 'inject.bin', language: 'us')
|
107
|
+
|
108
|
+
# Decode it back to verify the changes
|
109
|
+
decoded_script = Rubber::Ducky.decode('inject.bin')
|
110
|
+
puts decoded_script
|
111
|
+
```
|
112
|
+
|
113
|
+
### Working with Different Languages
|
114
|
+
|
115
|
+
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:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'de')
|
119
|
+
```
|
120
|
+
|
121
|
+
Similarly, to decode a file encoded with the German layout:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
decoded_script = Rubber::Ducky.decode('inject.bin', language: 'de')
|
125
|
+
```
|
126
|
+
|
127
|
+
## Professional Tips and Tricks
|
128
|
+
|
129
|
+
For advanced users, here are some tips to make the most of the `rubber-ducky` library.
|
130
|
+
|
131
|
+
### Integrating with Other Tools
|
132
|
+
|
133
|
+
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:
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
class PayloadsController < ApplicationController
|
137
|
+
def create
|
138
|
+
script = params[:script]
|
139
|
+
file_path = Rails.root.join('tmp', 'inject.bin')
|
140
|
+
|
141
|
+
Rubber::Ducky.encode(script, output: file_path, language: 'us')
|
142
|
+
|
143
|
+
send_file file_path, type: 'application/octet-stream', filename: 'inject.bin'
|
144
|
+
end
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
148
|
+
### Error Handling
|
149
|
+
|
150
|
+
The library is designed to be robust, but you should still handle potential errors gracefully:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
begin
|
154
|
+
Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'us')
|
155
|
+
rescue StandardError => e
|
156
|
+
puts "An error occurred during encoding: #{e.message}"
|
157
|
+
end
|
158
|
+
```
|
159
|
+
|
160
|
+
### Best Practices
|
161
|
+
|
162
|
+
- **Test your payloads**: Always test your payloads in a safe environment before deploying them.
|
163
|
+
- **Use version control**: Keep your scripts under version control to track changes and collaborate with others.
|
164
|
+
- **Stay updated**: Keep the library and your Ruby version up to date to avoid compatibility issues.
|
165
|
+
|
166
|
+
## Contributing
|
167
|
+
|
168
|
+
We welcome contributions! If you'd like to contribute to this project, please fork the repository and submit a pull request.
|
169
|
+
|
170
|
+
## License
|
171
|
+
|
172
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
173
|
+
|
174
|
+
---
|
175
|
+
|
176
|
+
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!
|
177
|
+
# rubber-ducky
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rake/testtask'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
# Task to run tests using RSpec
|
5
|
+
Rake::TestTask.new do |t|
|
6
|
+
t.libs << "spec"
|
7
|
+
t.test_files = FileList['spec/**/*_spec.rb']
|
8
|
+
t.verbose = true
|
9
|
+
end
|
10
|
+
|
11
|
+
# Task to install the gem locally
|
12
|
+
desc "Build and install the gem locally"
|
13
|
+
task :install do
|
14
|
+
sh "gem build rubber-ducky.gemspec"
|
15
|
+
sh "gem install rubber-ducky-#{Rubber::Ducky::VERSION}.gem"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Task to run RuboCop for code linting
|
19
|
+
desc "Run RuboCop for code quality"
|
20
|
+
task :rubocop do
|
21
|
+
sh "rubocop"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Task to generate documentation using Yard
|
25
|
+
desc "Generate YARD documentation"
|
26
|
+
task :yard do
|
27
|
+
sh "yard doc"
|
28
|
+
end
|
29
|
+
|
30
|
+
# Task to release the gem to RubyGems
|
31
|
+
desc "Release the gem to RubyGems"
|
32
|
+
task :release => [:install] do
|
33
|
+
sh "gem push rubber-ducky-#{Rubber::Ducky::VERSION}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
# Default task is to run tests
|
37
|
+
task :default => :test
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'rubber-ducky'
|
2
|
+
|
3
|
+
# لتشفير المحتوى من ملف وكتابته إلى ملف
|
4
|
+
encode = Rubber::Ducky.encode('payload.txt', output: 'inject.bin', language: 'us') # or without language to set by default
|
5
|
+
|
6
|
+
# لفك تشفير الملف وكتابة المحتوى المفكك إلى ملف
|
7
|
+
decode = Rubber::Ducky.decode('inject.bin', output: 'payload-decode.txt', language: 'us')
|
8
|
+
|
9
|
+
puts "Decoded content:"
|
10
|
+
puts decode
|