Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported opcode: JUMP_BACKWARD error #421

Closed
sinoST opened this issue Jan 2, 2024 · 15 comments
Closed

Unsupported opcode: JUMP_BACKWARD error #421

sinoST opened this issue Jan 2, 2024 · 15 comments

Comments

@sinoST
Copy link

sinoST commented Jan 2, 2024

this is my samples.
sample.zip
C:\tools\pycdc-master\pycdc-master\Debug>pycdc.exe sample.pyc >> sample.py Unsupported opcode: JUMP_BACKWARD Error decompyling sample.pyc: invalid vector subscript
how did i solve this problem?

@greenozon
Copy link
Contributor

easy - add code to support this new opcode
image

here is a draft result

sample-issue421.cdc1.txt

@sinoST
Copy link
Author

sinoST commented Jan 3, 2024

thank you very much! how to using new opcode?

@FedeGioz
Copy link

FedeGioz commented Jan 3, 2024

Can you make a pull request to support new opcode?

@greenozon
Copy link
Contributor

yeah, but 1st need to solve existing pending PR - #411
if you have time & desire - please invest some time into it as well!

@Bang1338
Copy link

Bang1338 commented Jan 22, 2024

i wonder where i can put that bytecode (JUMP_BACKWARD) in ASTree.cpp?

@greenozon
Copy link
Contributor

I've got 2 ideas:

  1. in the same case as Pyc::JUMP_ABSOLUTE_A
  2. nearby the JUMP_FORWARD_A

@Bang1338
Copy link

  1. in the same case as Pyc::JUMP_ABSOLUTE_A
  2. nearby the JUMP_FORWARD_A

change in bytecode.cpp and bytecode_ops.inl too?

@greenozon
Copy link
Contributor

well, AFAIK pycdc already knows all the opcodes up to version 3.12 inclusive
so those 2 mentioned modules should be already fine
are you using the last master branch?

@Bang1338
Copy link

are you using the last master branch?

Yes, i'm using the last master branch.

@Bang1338
Copy link

Bang1338 commented Jan 22, 2024

  1. in the same case as Pyc::JUMP_ABSOLUTE_A

Here,

/...
                    ifblk->init(popped);

                blocks.push(ifblk.cast<ASTBlock>());
                curblock = blocks.top();
            }
            break;
		case Pyc::JUMP_BACKWARD:
        case Pyc::JUMP_ABSOLUTE_A:
            {
                int offs = operand;
                if (mod->verCompare(3, 10) >= 0)
                    offs *= sizeof(uint16_t); // // BPO-27129

                if (offs < pos) {
/...

When i compiling:

  ASTree.cpp
C:\Users\Admin\pycdc\ASTree.cpp(1172,13): error C2039: 'JUMP_BACKWARD': is not a member of 'Pyc' [C:\Users\Admin\pycdc\
pycdc.vcxproj]
C:\Users\Admin\pycdc\bytecode.h(5,11): message : see declaration of 'Pyc' [C:\Users\Admin\pycdc\pycdc.vcxproj]
C:\Users\Admin\pycdc\ASTree.cpp(1172,13): error C2065: 'JUMP_BACKWARD': undeclared identifier [C:\Users\Admin\pycdc\pyc
dc.vcxproj]
C:\Users\Admin\pycdc\ASTree.cpp(1172,3): error C2051: case expression not constant [C:\Users\Admin\pycdc\pycdc.vcxproj]
Done Building Project "C:\Users\Admin\pycdc\pycdc.vcxproj" (default targets) -- FAILED.


Build FAILED.

"C:\Users\Admin\pycdc\pycdc.vcxproj" (default target) (1) ->
(ClCompile target) ->
  C:\Users\Admin\pycdc\ASTree.cpp(1172,13): error C2039: 'JUMP_BACKWARD': is not a member of 'Pyc' [C:\Users\Admin\pycd
c\pycdc.vcxproj]
  C:\Users\Admin\pycdc\ASTree.cpp(1172,13): error C2065: 'JUMP_BACKWARD': undeclared identifier [C:\Users\Admin\pycdc\p
ycdc.vcxproj]
  C:\Users\Admin\pycdc\ASTree.cpp(1172,3): error C2051: case expression not constant [C:\Users\Admin\pycdc\pycdc.vcxpro
j]

    0 Warning(s)
    3 Error(s)

Time Elapsed 00:00:10.20

Now I add JUMP_BACKWARD to bytecode_ops.inl

OPCODE(RETURN_GENERATOR)                // Python 3.11 ->
OPCODE(ASYNC_GEN_WRAP)                  // Python 3.11
OPCODE(PREP_RERAISE_STAR)               // Python 3.11
OPCODE(JUMP_BACKWARD)                   // Python 3.11, the one that missing.
OPCODE(INTERPRETER_EXIT)                // Python 3.12 ->
OPCODE(END_FOR)                         // Python 3.12 ->
OPCODE(END_SEND)                        // Python 3.12 ->

Recompile pycdc

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:43.75

I tried with this pyc file

>pycdc.exe main.pyc
# Source Generated with Decompyle++
# File: main.pyc (Python 3.11)

Unsupported opcode: JUMP_BACKWARD
from keyauth import api
import sys
import time
import platform
import os
import hashlib
from time import sleep
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
from time import sleep
from colorama import Fore, Style, init
import ctypes

def clear():
Error decompyling main.pyc: invalid vector subscript

Am I missing something?

@greenozon
Copy link
Contributor

'JUMP_BACKWARD': is not a member of 'Pyc'
-->>
JUMP_BACKWARD_A

@Bang1338
Copy link

'JUMP_BACKWARD': is not a member of 'Pyc' -->> JUMP_BACKWARD_A

okay thank my bad, i'll try again

@Bang1338
Copy link

Bang1338 commented Jan 22, 2024

'JUMP_BACKWARD': is not a member of 'Pyc' -->> JUMP_BACKWARD_A

UPDATE:

  1. in the same case as Pyc::JUMP_ABSOLUTE_A
>pycdc.exe main.pyc
# Source Generated with Decompyle++
# File: main.pyc (Python 3.11)

Warning: block stack is not empty!
from keyauth import api
import sys
import time
import platform
import os
import hashlib
from time import sleep
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
from time import sleep
from colorama import Fore, Style, init
import ctypes

def clear():
Error decompyling main.pyc: invalid vector subscript
  1. nearby the JUMP_FORWARD_A
>pycdc.exe main.pyc
# Source Generated with Decompyle++
# File: main.pyc (Python 3.11)

from keyauth import api
import sys
import time
import platform
import os
import hashlib
from time import sleep
from datetime import datetime
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, ElementNotInteractableException
from time import sleep
from colorama import Fore, Style, init
import ctypes

def clear():
Error decompyling main.pyc: invalid vector subscript

Opcode solved, but vector thing...

@greenozon
Copy link
Contributor

try to figure out where does that come from
is it due to newly added opcode or it might be totally different issue not related at all..

@zrax
Copy link
Owner

zrax commented Feb 21, 2024

Duplicate #452

@zrax zrax closed this as completed Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants