简体   繁体   中英

Save MacOS terminal output in a HID Script variable

I've been messing around with P4wnP1, trying to do pen testing with MacOS. In order for my program to work, I need to save a local IP address in a text file using HID Script.

The code goes as follows:

//Language and typing speed
layout('us')
typingSpeed(0,0)

//Open terminal
press(“GUI” + “SPACE”)
type(“terminal”)
press(“ENTER”)
delay(500)

//Find local IP address
type(“export IP_ADDR=/ipconfig getifaddr en0”)
press(“ENTER”)
//**Export IP_ADDR to .txt file in pi0w home directory**

Currently, I can get the correct output, but I do not know how to extract the data

Edit: I forgot to mention, HIDScript is based on JavaScript, with common libraries available

If the requirement is to capture the IP in a text file then you can use a pipe like this:

type(“export IP_ADDR=/ipconfig getifaddr en0 >/tmp/ipaddr.txt\n”)

Note: \\n means you don't have to use press enter line.

You could set up mass storage device in USB settings and save the text file there also..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM