Save MacOS terminal output in a HID Script variable

102 Views Asked by At

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

1

There are 1 best solutions below

0
On

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..