Sponsored Content
Full Discussion: Is this a Python 3.x.x bug?
Top Forums Programming Is this a Python 3.x.x bug? Post 302998839 by wisecracker on Thursday 8th of June 2017 02:36:16 PM
Old 06-08-2017
@ RudiC...
How about this then?
Code:
#!/bin/bash
echo "Inside bash shell here."
python3.5 "$HOME/Desktop/Code/Python/exit_malicious.py"
echo "Back inside bash shell with exit code $?..."

Code:
import os
print("Inside the Python script.")
text=10
text=input("Enter your text:- ")
exit(os.system(text))
print("This will never be reached...")

Result:-
Code:
Last login: Thu Jun  8 18:43:20 on ttys000
AMIGA:amiga~> cd Desktop/Code/Shell
AMIGA:amiga~/Desktop/Code/Shell> chmod 755 exit_malicious.sh
AMIGA:amiga~/Desktop/Code/Shell> ./exit_malicious.sh
Inside bash shell here.
Inside the Python script.
Enter your text:- echo "Launch my malicious code here whilst exiting Python..."
Launch my malicious code here whilst exiting Python...
Back inside bash shell with exit code 0...
AMIGA:amiga~/Desktop/Code/Shell> _

@Corona688...
No that was something entirely different using the shell's exit, it is on here I will find the pointer.

EDIT:
I appreciate this is hypothetical but if I can create this then a deep professional would know fully how to exploit it.

---------- Post updated at 07:36 PM ---------- Previous update was at 06:58 PM ----------

Quote:
Originally Posted by RudiC
For me, python is a large snake, or a flying circus, but what you show above would be the expected behaviour and absolutely makes sense to me. In the languages I know, exit (or similar) can take a value, even from a variable or a function, which becomes the program's "exit code". Why not deploy write's return value of 15? awk example:
Code:
awk 'END {X=7; exit X}'
echo $?
7

For values greater than 255, usually the lower byte is evaluated.
'END' just hangs on this machine so 'BEGIN' instead.
Hmmm, so this is normal proceedure?
Code:
Last login: Thu Jun  8 19:21:58 on ttys000
AMIGA:amiga~> awk --version
awk version 20070501
AMIGA:amiga~> awk 'BEGIN { x=13; x=system("ls -l"); exit x; }'
total 2120
-rwxr-xr-x   1 amiga  staff  217121 20 May 14:23 06500.sh.txt
-rw-r--r--   1 amiga  staff    5128 22 May 14:16 06500.txt
drwxr-xr-x   3 amiga  staff     102  2 Jan 15:42 Applications
-rw-r--r--   1 amiga  staff   20715  3 Jun 13:47 AudioScope.Circuits
-rw-r--r--   1 amiga  staff     315  3 Jun 13:47 AudioScope.Config
-rw-r--r--   1 amiga  staff  118305  3 Jun 13:47 AudioScope.Manual
-rwxr-xr-x   1 amiga  staff  220419  3 Jun 12:00 AudioScope.sh
-rwxr-xr-x   1 amiga  staff  220418  3 Jun 11:45 AudioScope.sh~
-rw-r--r--   1 amiga  staff  220047 24 May 18:35 AudioScope24-05-2017.sh
-rw-r--r--   1 amiga  staff    6307  3 Jun 13:47 AudioScope_Quick_Start.Notes
drwx------+ 12 amiga  staff     408  3 Jun 20:25 Desktop
drwx------+  8 amiga  staff     272 31 Dec 15:23 Documents
drwx------+ 22 amiga  staff     748  7 Jun 13:12 Downloads
drwx------@ 58 amiga  staff    1972 18 May 18:08 Library
drwx------+  3 amiga  staff     102 24 Oct  2016 Movies
drwx------+  6 amiga  staff     204 14 Dec 22:16 Music
-rwxr-xr-x   1 amiga  staff     751 18 May 17:39 NewCLI
drwx------+  6 amiga  staff     204 16 May 14:23 Pictures
drwxr-xr-x   3 amiga  staff     102 11 Dec 17:34 Programs
drwxr-xr-x+  6 amiga  staff     204 18 May 18:36 Public
drwxr-xr-x  56 amiga  staff    1904 18 May 17:45 Scope
drwxr-xr-x  27 amiga  staff     918  3 Jun 12:01 Temp
drwxr-xr-x   4 amiga  staff     136 14 Oct  2016 URL
-rw-r--r--   1 amiga  staff   28518 31 May 20:00 sample.txt
drwxr-xr-x@ 14 amiga  staff     476  7 Nov  2016 sox-14.4.2
-rwxr-xr-x   1 amiga  staff     751 20 May 09:07 xterm
AMIGA:amiga~> echo "Return code, $?..."
Return code, 0...
AMIGA:amiga~> _


Last edited by wisecracker; 06-08-2017 at 03:37 PM.. Reason: See EDIT.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Is it a bug ..?

Hi All, I am using Red Hat Linux on my servers. The problem that I am facing is, sometimes the /opt usage on the server shows used percentage as 100% , when actually it is simply 20%. When I reboot the system, it comes back to 20%.Is this a bug in the system or my settings have gone wrong... (1 Reply)
Discussion started by: nua7
1 Replies

2. AIX

bug in 43 ???

xxxxserver# lsattr -El inet0 | grep 255.240.0.0,32.224.0.0,32.78.120.254 | grep '.40' route net,-hopcount,1,-netmask,255.240.0.0,32.224.0.0,32.78.120.254 How this is possible? (1 Reply)
Discussion started by: itik
1 Replies

3. UNIX for Dummies Questions & Answers

where's the bug?

#!/bin/bash if then #echo "infinite loop" exit 0 fi when I run this file I get the following error: ./test_infinite_loop: line 5: syntax error near unexpected token `fi' ./test_infinite_loop: line 5: `fi' :confused: (4 Replies)
Discussion started by: jon80
4 Replies

4. SuSE

"ssh suse-server 'python -V' > python-version.out" not redirecting

Okay, so I have had this problem on openSUSE, and Debian systems now and I am hoping for a little help. I think it has something to do with Python but I couldn't find a proper Python area here. I am trying to redirect the output of "ssh suse-server 'python -V'" to a file. It seems that no matter... (3 Replies)
Discussion started by: Druonysus
3 Replies

5. Shell Programming and Scripting

**python** unable to read the background color in python

I am working on requirement on spreadsheet in python scripting. I have a spreadsheet containing cell values and with background color. I am able to read the value value but unable to get the background color of that particular cell. Actually my requirement is to read the cell value along... (1 Reply)
Discussion started by: giridhar276
1 Replies

6. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

7. Windows & DOS: Issues & Discussions

How to execute python script on remote with python way..?

Hi all, I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine.. Below is the code I am trying: #!/usr/bin/env python import wmi c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
Discussion started by: onenessboy
1 Replies

8. Programming

Create a C source and compile inside Python 1.4.0 to 3.7.0 in Python for ALL? platforms...

Hi all... As you know I like making code backwards compatible for as many platforms as possible. This Python script was in fact dedicated for the AMIGA A1200 using Pythons 1.4.0, 1.5.2, 1.6.0, 2.0.1, and 2.4.6 as that is all we have for varying levels of upgrades from a HDD and 4MB FastRam... (1 Reply)
Discussion started by: wisecracker
1 Replies
All times are GMT -4. The time now is 08:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy