qiling icon indicating copy to clipboard operation
qiling copied to clipboard

Rewrite in Rust

Open XVilka opened this issue 4 years ago • 18 comments

Python is a poor choice for anything remotely complex, especially that affects the execution times like emulation. Projects like Angr and Miasm met a bottleneck of Python, it's slowness, GIL, memory hunger, and poor parallelism. On the other hand, reimplementing most of the code in Rust will still allow to provide Python interface, see Rust-Python example.

XVilka avatar Apr 26 '20 07:04 XVilka

Hi,

You are right. I am not too sure about Angr but we are definitely more complex then miasm.

So, if someone can start to implement Rust-Python in QIling. We will be really happy.

xwings avatar Apr 26 '20 08:04 xwings

In fact @xwings has answered this in a Podcast, basically

  1. friendly for developers and new coming contributors
  2. code base could be a good learning material (especially for students who want to learn OS internals)
  3. just enough libraries to base on (unicorn engine, etc)

ttimasdf avatar Jun 09 '20 02:06 ttimasdf

Miasm folks are rewriting it in Rust too, by the way.

XVilka avatar Jun 09 '20 02:06 XVilka

i am pretty sure is a good idea. but do we need it or not now will be the questions.

i am not familiar with MIASM. so, i cannot comment.

xwings avatar Jun 09 '20 03:06 xwings

I like this idea. But it seems to require a lot of work.

@XVilka I read your link about Rust-Python. It is about to make rust libraries for python. It is nice for people who will need to import our project in python but can we import python in rust to avoid to recode everything?

Is there a way to avoid to recode everything?

gogo2464 avatar Jun 09 '20 17:06 gogo2464

@XVilka Your link https://github.com/rochacbruno/rust-python-example might be deprecated. See https://users.rust-lang.org/t/try-keyword-reservation-breaks-macro-try/23398 and https://github.com/rochacbruno/rust-python-example/issues/21

gogo2464 avatar Jun 09 '20 22:06 gogo2464

@xwings I do not understand why you closed this issue. We think rust is a good choice and all has not been replaced.

gogo2464 avatar Aug 13 '20 11:08 gogo2464

i think re-write with unicorn rust binding will be a good idea, but it seems deprecated.

ucgJhe avatar Aug 13 '20 11:08 ucgJhe

Has there been any progress on this issue? I'd like to contribute to this if possible. This is a big task though, and I don't think it will happen unless we can get a few core people to divide up the work and contribute consistently. Is anyone actively working on this? Or is anyone interested in working on this?

0xchase avatar Dec 14 '20 14:12 0xchase

@0xchase I noticed that I could make a rust library and import it in python see here because it is easier than import python in rust.

I did not do more yet.

gogo2464 avatar Dec 14 '20 14:12 gogo2464

Const is a rust keyword. I can not create a const crate instead of this. Do I open an issue to rename this file in order to replace it with a crate?

gogo2464 avatar Dec 14 '20 15:12 gogo2464

reopened.

xwings avatar Dec 15 '20 01:12 xwings

I wrote a similar implementation in rust. Only realized loading windows pe. Lack of gdtr implementation, tls implementation and api hook. It used to be when a private project was implemented, and I saw people have similar ideas, so I will make it public here, and will continue to update.

https://github.com/edsky/muhe

edsky avatar Jan 14 '21 06:01 edsky

I just found a tool to translate c code to rust https://c2rust.com/ I am looking for a similar program from python to rust. It does not do everything but could help a lot.

gogo2464 avatar Apr 12 '21 22:04 gogo2464

DONE! This tools may help very much : https://github.com/konchunas/pyrs !

gogo2464 avatar Apr 12 '21 22:04 gogo2464

Assign me to this issue immediately :)

gogo2464 avatar Apr 12 '21 22:04 gogo2464

@gogo2464 I can guarantee the automatic transpile will be more difficult than rewriting it from scratch and probably won't work at all

0xchase avatar Apr 13 '21 00:04 0xchase

Yup. I agree.

xwings avatar Jun 09 '21 07:06 xwings

Close for now. Did not see light at the end of tunnel.

xwings avatar Oct 06 '22 03:10 xwings