Coder Social home page Coder Social logo

Doesn't compile on Kali about sandsifter HOT 6 OPEN

cdefender avatar cdefender commented on June 27, 2024
Doesn't compile on Kali

from sandsifter.

Comments (6)

paulmenzel avatar paulmenzel commented on June 27, 2024 8

Yes, doing the change below fixes the problem.

-       $(CC) $(CFLAGS) $< -O3 -Wall -l:libcapstone.a -o $@ -pthread
+       $(CC) $(CFLAGS) $< -O3 -Wall -no-pie -l:libcapstone.a -o $@ -pthread

from sandsifter.

paulmenzel avatar paulmenzel commented on June 27, 2024 2

This happens only when building with -fPIC, right? On Debian Sid/unstable, just running make I get the error below.

$ make
cc  -c injector.c -o injector.o -Wall
[…]
cc  injector.o -O3 -Wall -l:libcapstone.a -o injector -pthread
/usr/bin/ld: injector.o: relocation R_X86_64_32S against undefined symbol `dummy_stack' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Makefile:35: recipe for target 'injector' failed
make: *** [injector] Error 1

Then building with -fPIC, your error can be reproduced.

$ make CFLAGS="-fPIC"
cc -fPIC -c injector.c -o injector.o -Wall
[…]
injector.c: In function ‘inject’:
injector.c:778:2: warning: asm operand 15 probably doesn’t match constraints
  __asm__ __volatile__ ("\
  ^~~~~~~
injector.c:778:2: error: impossible constraint in ‘asm’
Makefile:38: recipe for target 'injector.o' failed
make: *** [injector.o] Error 1

from sandsifter.

ggramaize avatar ggramaize commented on June 27, 2024

I reproduce exactly paulmenzel's result on Debian stretch with the following environment:

# cc --version
cc (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# apt-cache policy python3-capstone libcapstone3 libcapstone-dev python-capstone
python3-capstone:
  Installé : 3.0.4-1
  Candidat : 3.0.4-1
 Table de version :
 *** 3.0.4-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status
libcapstone3:
  Installé : 3.0.4-1
  Candidat : 3.0.4-1
 Table de version :
 *** 3.0.4-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status
libcapstone-dev:
  Installé : 3.0.4-1
  Candidat : 3.0.4-1
 Table de version :
 *** 3.0.4-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status
python-capstone:
  Installé : 3.0.4-1
  Candidat : 3.0.4-1
 Table de version :
 *** 3.0.4-1 500
        500 http://ftp.fr.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

from sandsifter.

f4grx avatar f4grx commented on June 27, 2024

probably unrelated but I compiled capstone master from scratch instead of using version from package managers.

from sandsifter.

LeoAdamek avatar LeoAdamek commented on June 27, 2024

@f4grx have a look at #2 -- Try adding -no-pie to the linker step, it resolves the exact same issue I had on Arch.

from sandsifter.

Thiefyface avatar Thiefyface commented on June 27, 2024

I can get it to compile by changing the following:

+ [esp]"p"(&dummy_stack.dummy_stack_lo),
-  [esp]"i"(&dummy_stack.dummy_stack_lo),

But I'm not entirely sure if the p constraint is correct. The binary tends to only run through 1 iteration after compilation. I'm thinking that the issue has to do with the fact that since I'm running this on an x86 system, and the dummy_stack struct members are both 64 bits, it's trying to read in a 64 bit value into a memory operand, which is probably no bueno.

Could prob just patch to add a macro based on system architecture for this structure.

from sandsifter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.