Created
December 21, 2016 01:26
-
-
Save Hacksore/aa3634060a9cfa395f430e2275b5c626 to your computer and use it in GitHub Desktop.
Southwest Auto Checkin PoC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rp = require("request-promise"); | |
var fs = require("fs"); | |
var db = JSON.parse(fs.readFileSync("db.json")); | |
var jar = rp.jar(); | |
const CONFIG_EMAIL = "<insert email>"; | |
checkIn({"confirmationNumber": "GGEZ69", "firstName": "Joe", "lastName": "Shmoe"}); | |
function checkIn(user){ | |
user.submitButton = "Check In"; | |
var flightNumber; | |
return rp({ | |
url: "https://www.southwest.com", | |
jar: jar | |
}) | |
.then(function(data){ | |
return rp({ | |
method: "post", | |
url: "https://www.southwest.com/flight/retrieveCheckinDoc.html", | |
form: user, | |
jar: jar | |
}); | |
}) | |
.then(function(res){ | |
if(db[user.confirmationNumber] !== undefined){ //check if we have checked in already | |
throw new Error("Already checked in!"); | |
} | |
var failed = res.search("Boarding Pass is more than 24 hours prior") > -1 ? true : false; | |
if(!failed){ | |
return rp({ | |
method: "post", | |
url: "https://www.southwest.com/flight/selectPrintDocument.html", | |
form: { | |
"checkinPassengers[0]selected": "true", | |
"printDocuments": "Check In" | |
}, | |
jar: jar | |
}) | |
} | |
}) | |
.then(function(res){ | |
return rp({ | |
method: "get", | |
url: "https://www.southwest.com/flight/selectCheckinDocDelivery.html?int=", | |
jar: jar | |
}); | |
}) | |
.then(function(res){ | |
var regex = /<span class="number">(.*?)<\/span>/g; | |
var result = regex.exec(res); | |
if(result === null){ | |
throw new Error("Can't find a flight for confirmation number: " + user.confirmationNumber); | |
} | |
flightNumber = result[1]; | |
return rp({ | |
method: "post", | |
followAllRedirects: true, | |
url: "https://www.southwest.com/flight/selectCheckinDocDelivery.html", | |
form: { | |
selectedOption: "optionEmail", | |
emailAddress: CONFIG_EMAIL | |
}, | |
jar: jar | |
}) | |
}) | |
.then(function(data){ | |
var status = data.search("Your Boarding Pass has been") > -1 ? true : false; | |
if(status){ | |
console.log("Autocheckin for Flight# " + flightNumber + " was succesful"); | |
console.log("A bording pass email was sent to " + CONFIG_EMAIL); | |
db[user.confirmationNumber] = true; | |
fs.writeFileSync("db.json", JSON.stringify(db)) | |
} | |
}) | |
.catch(function(err){ | |
console.log(err.message); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment