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

Rex::Arch.adjust_stack_pointer supports only x86 #12378

Open
wvu opened this issue Oct 1, 2019 · 4 comments
Open

Rex::Arch.adjust_stack_pointer supports only x86 #12378

wvu opened this issue Oct 1, 2019 · 4 comments
Labels
enhancement library suggestion Suggestions for new functionality

Comments

@wvu
Copy link
Contributor

wvu commented Oct 1, 2019

Update it to support x64. I think it's fine to continue using Rex::Arch::X86 (there's no Rex::Arch::X64), since if you need more than 2^32 bytes of adjustment, you're gonna have a bad time.

  #
  # This routine adjusts the stack pointer for a given architecture.
  #
  def self.adjust_stack_pointer(arch, adjustment)


    if arch.is_a?(::Array)
      arch = arch[0]
    end


    case arch
      when /x86/
        Rex::Arch::X86.adjust_reg(Rex::Arch::X86::ESP, adjustment)
      else
        nil
    end
  end

#12377

@wvu wvu added library enhancement suggestion Suggestions for new functionality labels Oct 1, 2019
@bcoles
Copy link
Contributor

bcoles commented Oct 4, 2019

Was this a bug ? Was this issue closed by #12377 ?

@wvu wvu self-assigned this Oct 5, 2019
@wvu
Copy link
Contributor Author

wvu commented Oct 5, 2019

Don't think so. Updated description.

@bcoles
Copy link
Contributor

bcoles commented Dec 24, 2019

On a related note, adjust_stack_pointer is called only once in Framework (perhaps used elsewhere in other other libs), and features this:

    # Default to x86 if we can't find a list of architectures
    if arch && !arch.empty?
      arch = [arch].flatten.join(', ')
    else
      arch = 'x86'
    end

    Rex::Arch::adjust_stack_pointer(arch, adj) || ''

Rex::Arch::adjust_stack_pointer accepts an array - may as well give it one, rather than a comma separated string.

Edit: This may break the following case arch statement, as only the first element of the array is used, and the case performs a regular expression match on x86. This would work for a string containing multiple architectures, but not on an array. This seems like an oversight of the case statement. I'm also not sure how common it would be for multiple architectures to ever reach this method.

@wvu
Copy link
Contributor Author

wvu commented Dec 24, 2019

Great catch.

@wvu wvu removed their assignment Sep 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement library suggestion Suggestions for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants