public
Authored by avatar cleemy desu wayo

a sample of [cdwdoc-2023-001], call me maybe (from external)

in general, all shell scripts can be called from external programs, unless they assume interactive use only.

if https://gitlab.com/-/snippets/2494925 and this sample behave as I intended, it should look like this:

$ ./cdwdoc-2023-001_from_external.rb
true
false
false
true
nil

the execution environment is as follows:

$ ruby --version
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-linux-gnu]
$ cat /proc/version
Linux version 6.0.0-kali3-amd64 (devel@kali.org) (gcc-12 (Debian 12.2.0-3) 12.2.0, GNU ld (GNU Binutils for Debian) 2.39) #1 SMP PREEMPT_DYNAMIC Debian 6.0.7-1kali1 (2022-11-07)

python edition:

$ ./cdwdoc-2023-001_from_external.py
True
False
False
True
None

the execution environment is as follows:

$ python -V
Python 3.10.8
$ cat /proc/version
Linux version 6.0.0-kali3-amd64 (devel@kali.org) (gcc-12 (Debian 12.2.0-3) 12.2.0, GNU ld (GNU Binutils for Debian) 2.39) #1 SMP PREEMPT_DYNAMIC Debian 6.0.7-1kali1 (2022-11-07)

some changes may be needed for old python (python 3.4.x or earlier)

        exit_status = subprocess.call(args=command_args, stderr=open('/dev/null', 'w'))
        return exit_status == 0

.

.

.

.

.

.

️ spoiler warning

if you have not solved https://gitlab.com/-/snippets/2494925 on your own, the following code may yield almost the direct answer

.

.

.

.

.

.

cdwdoc-2023-001_from_external.py 658 bytes
#!/usr/bin/env python3
# written by cleemy desu wayo / see [cdwdoc-2023-001] / Licensed under CC0 1.0

import subprocess

def user_authenticate(user, password):
    command_args = ['./cdwdoc-2023-001_challenge.sh', user, password]
    try:
        process = subprocess.run(args=command_args, stderr=subprocess.DEVNULL)
        return process.returncode == 0
    except Exception:
        return None

print(user_authenticate('user1', 'aaa'))
print(user_authenticate('user1', 'aaaa'))
print(user_authenticate('user1', 'a' * 100))
print(user_authenticate('user1', 'a' * 131071))  # change this line to your env
print(user_authenticate('user1', 'a' * 9999999))
cdwdoc-2023-001_from_external.rb 453 bytes
#!/usr/bin/env ruby
# written by cleemy desu wayo / see [cdwdoc-2023-001] / Licensed under CC0 1.0

def user_authenticate(user, password)
  system('./cdwdoc-2023-001_challenge.sh', user, password, :err=>'/dev/null')
end

p user_authenticate('user1', 'aaa')
p user_authenticate('user1', 'aaaa')
p user_authenticate('user1', 'a' * 100)
p user_authenticate('user1', 'a' * 131071)  # change this line to your env
p user_authenticate('user1', 'a' * 9999999)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment