From a7f0aee8b273cdf519c154d7323c1543e67f1cef Mon Sep 17 00:00:00 2001 From: Security Curious Date: Wed, 10 Nov 2021 21:19:51 -0500 Subject: [PATCH 1/3] Add Ruby examples Include all strategies tested in other languages. For comment out and early return the strategy needed to be modified in order to make it work but the idea still works. Unlike the other languages invisible functions do work in Ruby since any unicode character can be put in a method name. --- Ruby/README.md | 29 +++++++++++++++++++++++++++++ Ruby/commenting-out.rb | 6 ++++++ Ruby/early-return.rb | 11 +++++++++++ Ruby/homoglyph-function.rb | 11 +++++++++++ Ruby/invisible-functions.rb | 13 +++++++++++++ Ruby/stretched-string.rb | 6 ++++++ 6 files changed, 76 insertions(+) create mode 100644 Ruby/README.md create mode 100755 Ruby/commenting-out.rb create mode 100755 Ruby/early-return.rb create mode 100755 Ruby/homoglyph-function.rb create mode 100755 Ruby/invisible-functions.rb create mode 100755 Ruby/stretched-string.rb diff --git a/Ruby/README.md b/Ruby/README.md new file mode 100644 index 0000000..0f7bad3 --- /dev/null +++ b/Ruby/README.md @@ -0,0 +1,29 @@ +# Ruby + +## Commenting-Out + +Because of the lack of comments with a closing token this doesn't work +the same way as other languages. For more info see: + +https://github.com/nickboucher/trojan-source/issues/8#issuecomment-962468707 + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Early Return + +Also dues not work the same as other languages because of lack of closing token +on comments. See same link as above. + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Homoglyph Function + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Invisible Function + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched String + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] diff --git a/Ruby/commenting-out.rb b/Ruby/commenting-out.rb new file mode 100755 index 0000000..1fe8942 --- /dev/null +++ b/Ruby/commenting-out.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +is_admin = false +⁧⁦ = true; #⁩⁦if is_admin # Begin block if is_admin⁩⁩ + puts 'You are an admin.' +⁧⁦ = true; #⁩⁦end # End block if is_admin ⁩⁩ diff --git a/Ruby/early-return.rb b/Ruby/early-return.rb new file mode 100755 index 0000000..165ae78 --- /dev/null +++ b/Ruby/early-return.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +$bank = { 'alice' => 100 } + +def subtract_funds account, amount + ⁧⁦ = amount and return # ⁩⁦# Subtract from acct the value⁩⁩ + $bank[account] -= amount +end + +subtract_funds 'alice', 50 +puts $bank.inspect diff --git a/Ruby/homoglyph-function.rb b/Ruby/homoglyph-function.rb new file mode 100755 index 0000000..d635b57 --- /dev/null +++ b/Ruby/homoglyph-function.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +def sayНello + puts "Goodbye, World!" +end + +def sayHello + puts "Hello, World!" +end + +sayНello diff --git a/Ruby/invisible-functions.rb b/Ruby/invisible-functions.rb new file mode 100755 index 0000000..6fb7b5e --- /dev/null +++ b/Ruby/invisible-functions.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +def is_admin + false +end + +def is_​admin + true +end + +if is_​admin + puts "You are an admin." +end diff --git a/Ruby/stretched-string.rb b/Ruby/stretched-string.rb new file mode 100755 index 0000000..2085bf3 --- /dev/null +++ b/Ruby/stretched-string.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +access_level = "user" +if access_level != "user‮⁦" # Check if admin⁩⁦ + puts "You are an admin." +end From 49d8720b08eff8c0ac83fde9b02212b0c3050c78 Mon Sep 17 00:00:00 2001 From: Security Curious Date: Wed, 10 Nov 2021 21:34:44 -0500 Subject: [PATCH 2/3] New Ruby Strategies Some of these might be applicable to other languages. --- Ruby/README.md | 19 +++++++++++++++++++ Ruby/stretched-regex.rb | 10 ++++++++++ Ruby/stretched-string-list.rb | 7 +++++++ Ruby/stretched-variable.rb | 6 ++++++ 4 files changed, 42 insertions(+) create mode 100755 Ruby/stretched-regex.rb create mode 100755 Ruby/stretched-string-list.rb create mode 100755 Ruby/stretched-variable.rb diff --git a/Ruby/README.md b/Ruby/README.md index 0f7bad3..e59c65b 100644 --- a/Ruby/README.md +++ b/Ruby/README.md @@ -27,3 +27,22 @@ on comments. See same link as above. ## Stretched String - Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +# Variations + +Some variations that may or may not be applicable in other languages. For +more info see: + +https://github.com/nickboucher/trojan-source/issues/9 + +## Stretched Regexp + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched String List + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] + +## Stretched Variable + +- Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] diff --git a/Ruby/stretched-regex.rb b/Ruby/stretched-regex.rb new file mode 100755 index 0000000..1658cf9 --- /dev/null +++ b/Ruby/stretched-regex.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +$roles = 'user,manager' +def admin? + $roles =~ /admin⁧⁦|user/ #⁩⁦/ # Restrict from ⁩⁩ +end + +if admin? + puts 'You are an admin.' +end diff --git a/Ruby/stretched-string-list.rb b/Ruby/stretched-string-list.rb new file mode 100755 index 0000000..88ad3a6 --- /dev/null +++ b/Ruby/stretched-string-list.rb @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +role = 'User' +privileged = %w(Admin Manager⁧⁦ User) # ⁩⁦) # All roles (except ⁩⁩ +if privileged.include? role + puts 'You are an admin.' +end diff --git a/Ruby/stretched-variable.rb b/Ruby/stretched-variable.rb new file mode 100755 index 0000000..5b9dd2e --- /dev/null +++ b/Ruby/stretched-variable.rb @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +role⁧⁦= 'Admin' #⁩⁦ # Condition will ensure 'User' !⁩⁦ = 'User'⁩⁩ +if role⁧⁦ == 'Admin' + puts 'You are an admin.' +end From 2e2671bd55c7434e257f5abc92d38ddcc3e85e96 Mon Sep 17 00:00:00 2001 From: Security Curious Date: Wed, 10 Nov 2021 21:55:03 -0500 Subject: [PATCH 3/3] Ruby README.md fixes --- Ruby/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Ruby/README.md b/Ruby/README.md index e59c65b..06687f8 100644 --- a/Ruby/README.md +++ b/Ruby/README.md @@ -11,7 +11,7 @@ https://github.com/nickboucher/trojan-source/issues/8#issuecomment-962468707 ## Early Return -Also dues not work the same as other languages because of lack of closing token +Also does not work the same as other languages because of lack of closing token on comments. See same link as above. - Confirmed working on ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux] @@ -30,8 +30,7 @@ on comments. See same link as above. # Variations -Some variations that may or may not be applicable in other languages. For -more info see: +Variations that may or may not be applicable in other languages. More info at: https://github.com/nickboucher/trojan-source/issues/9