-
Notifications
You must be signed in to change notification settings - Fork 97
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
Is there an API for sending Control Transfers over usb? #354
Comments
Ok, so I didn't find what I'm looking for in In case anyone else plans on doing this, this is what worked for me: import os
from facedancer import FacedancerUSBHostApp
os.environ['BACKEND'] = 'greatfet'
dev = FacedancerUSBHostApp(verbose=5)
dev.initialize_device()
dev.control_request_in(...)
dev.control_request_out(...) I think my issue was that I just assumed that Some documentation would probably be helpful but the python code is definitely readable. That in combination with the comments is also enough to figure out how stuff works for the most part :) |
Turns out, that still doesn't work properly. Glitchkit and Facedancer appear to do different things when sending control requests. I still can't get the device to respond properly using facedancer. I can craft a setup request and send it using Here's my code to build the two requests and send them first using glitchkit's API and then using facedancer's. #!/usr/bin/env python3
import greatfet
import IPython
import usb_consts as consts
import facedancer
from facedancer import FacedancerUSBHostApp
def main():
# Get some objects to interface with the usb contoller
gf = greatfet.GreatFET()
dev = FacedancerUSBHostApp(verbose=5)
dev.initialize_device()
# Build setup request using glitchkit
req_glitch = gf.glitchkit.usb.build_setup_request(
True,
consts.REQUEST_TYPE_STANDARD, consts.REQUEST_RECIPIENT_DEVICE,
consts.REQUEST_GET_DESCRIPTOR, length = 0x100, index = 0,
value = (consts.USB_DT_STRING | consts.DESCRIPTOR_IDX_SN)
)
print(f"[i] req_glitch: {req_glitch}")
# Build setup request using facedancer
req_face = facedancer.core.FacedancerUSBHost._build_setup_request(
True,
consts.REQUEST_TYPE_STANDARD, consts.REQUEST_RECIPIENT_DEVICE,
consts.REQUEST_GET_DESCRIPTOR, length = 0x100, index = 0,
value = (consts.USB_DT_STRING | consts.DESCRIPTOR_IDX_SN)
)
print(f"[i] req_face: {req_face}")
assert(req_glitch == req_face)
# Send requst using glitchkit
resp_glitch = gf.glitchkit.usb.api.control_in(bytes(req_glitch), timeout=30*1024)
print(f"[IN glitch] {resp_glitch}")
# Send requst using facedancer
# I'll use the control_request_in method for that, but it builds the request
# to be sent itself using _build_setup_request.
#
# But since we already know that facedancer.core.FacedancerUSBHost._build_setup_request
# yields the same bytes as gf.glitchkit.usb.build_setup_request this shouldn't be an
# issue :)
resp_face = dev.control_request_in(
consts.REQUEST_TYPE_STANDARD, consts.REQUEST_RECIPIENT_DEVICE,
consts.REQUEST_GET_DESCRIPTOR, length = 0x100, index = 0,
value = (consts.USB_DT_STRING | consts.DESCRIPTOR_IDX_SN)
)
# IPython.embed() # now to debugging...
if __name__ == '__main__':
main() This is the output if I run the code and ^C it after a minute of hanging:
I don't actually care about whether I have to use facedancer's or glitchkit's APIs but AFAIK facedancer is the only one that also allows me to send |
With regard to Facedancer, have you tried running the |
@A2nkF Are you still experiencing this issue? |
@Qyriad - Running that script does fail:
But I don't know if my setup is particularly weird. It's a MBP with Catalina and python3.8 on the host side and the target is an iPhone X. I've also tried an iPhone 7, 11 and 12 pro and observed the same behaviour. @straithe - Yes, still the same issue. I just gave up on this project for now bc I spent a couple of days trying to get it to work and still had other things to work on. The thing that's throwing me off is that everything works fine if you use Thanks for looking into it and lmk if you need any more info :) |
Hi @A2nkF. We've updated Facedancer quite a bit in the last year. We are hoping your issue will be resolved with the new code. Can you please try again and let us know your results? |
Hey,
I'm trying to use my greatfet to send Control Transfers to a device connected through the USB1 port, but I didn't manage to find any APIs to do that :/
I think there is a higher level API to do
IN
control transfers ingf.glitchkit.usb.capture_control_in
but that doesn't quite cover what I'm trying to do.I also tried
~$ gf info -A
andbut there didn't seem to be an API to just send Control Transfers. Not even in
gf.apis.greatdancer
.Am I just looking in the wrong places or do I have to build a custom firmware to expose this functionality?
Thank you :D
The text was updated successfully, but these errors were encountered: