Cov txheej txheem:

Alexa, Kuv Cov Yuam Sij Nyob Qhov Twg?: 4 Kauj Ruam
Alexa, Kuv Cov Yuam Sij Nyob Qhov Twg?: 4 Kauj Ruam

Video: Alexa, Kuv Cov Yuam Sij Nyob Qhov Twg?: 4 Kauj Ruam

Video: Alexa, Kuv Cov Yuam Sij Nyob Qhov Twg?: 4 Kauj Ruam
Video: Jack GV - Kuv Thov Txim Ft. Vicky Yang (Official Audio) 2024, Hlis ntuj nqeg
Anonim
Image
Image
Hacking Bluetooth Beacons
Hacking Bluetooth Beacons

Alexa tshwj xeeb tshaj yog haum rau cov ntaub ntawv khaws cov haujlwm thiab saib xyuas cov cuab tam siv wireless network hauv tsev. Nws yog ib qho los txiav txim siab muab cov khoom muaj nqis tso rau ntawm daim phiaj kom tau txais sai. Peb hack pheej yig bluetooth lub zog qis beacons rau lub network ntau thiab roj teeb lub neej ntev thiab tsim cov ntawv thov ntse kom Alexa paub qhov twg peb tso cov yuam sij.

Yuav ua li cas nws …

Kauj ruam 1: Hacking Bluetooth Beacons

Ib txheej ntawm 3 beacons tuaj yeem yuav tau tsawg dua $ 15 thiab tau txais kev txhawb nqa nrog Android/iOS daim ntawv thov tab sis peb yuav xaiv qhov tsis pub lwm tus paub. Ib qho ntxiv, nrhiav peb cov yuam sij yuav tsum tsis tig mus nrhiav peb lub xov tooj.

Cov lus qhia adafruit no ntawm kev thim rov qab engineering ntse teeb tau pab peb tswj cov beacons. Pib los ntawm kev qhib lub teeb nyem scan rau lub cuab yeej chaw nyob los ntawm kev khiav:

sudo hcitool lescan

Nrhiav & luam qhov chaw nyob uas sau nrog lub npe 'iTag,' tom qab ntawd khiav:

sudo gatttool -I

Txuas mus rau lub cuab yeej sib cuam tshuam los ntawm kev khiav:

txuas AA: BB: CC: DD: EE: FF

Sim khiav 'pab' los saib cov kev xaiv lossis 'thawj' los saib cov kev pabcuam:

Khiav 'char-desc' ua raws li cov kev pabcuam ua haujlwm saum toj no, peb pom UUIDs uas peb saib los ntawm kev hais txog cov yam ntxwv tshwj xeeb gatt thiab cov kev qhia tshwj xeeb. Yog xav paub ntau ntxiv ntawm cov kev pabcuam no, txheeb xyuas qhov no. Kuv pom kev sib tw nrog Wireshark, peb pom tias 0100111000000001 ua rau lub tswb ceeb toom thiab muaj txiaj ntsig, 0000111000000001 tig nws tawm. Tam sim no peb muaj qhov ua haujlwm nab hab sej yooj yim:

ntshuam pexpectdef sound_alarm (BD_ADDR): tus menyuam = pexpect.spawn ('gatttool -I') child.sendline ('txuas {}'. hom ntawv (BD_ADDR)) child.expect ('Kev sib txuas tau zoo', sijhawm = 30) child.sendline ('char-write-cmd 0x000b 0100111000000001')

Tom ntej no, peb tsom mus rau tsim Alexa txuj ci los ua lub teeb ci thaum peb tab tom nrhiav cov yuam sij.

Kauj Ruam 2: Tsim Alexa Skill thiab App

Tsim Alexa Skill thiab App
Tsim Alexa Skill thiab App
Tsim Alexa Skill thiab App
Tsim Alexa Skill thiab App

Peb tsim cov txuj ci uas yuav txuas rau lub server hauv zos. Tom qab ntawd peb teeb tsa peb cov neeg rau zaub mov kom ua txhua yam peb xav tau, hauv qhov no, muab kwv yees kwv yees qhov twg cov yuam sij yuav nyob thiab ua Bluetooth beacon beep. Flask muab cov ntaub ntawv yooj yim thiab yooj yim siv nab nab los ua haujlwm rau daim ntawv thov. Siv lub raj mis-nug, peb tuaj yeem teeb tsa lub server kom sib txuas lus nrog peb cov txuj ci Alexa peb mam tsim tom qab. Ua tau zoo thov daim ntawv thov nrog Ngrok, uas yuav muab rau peb txuas https peb yuav xav tau rau peb qhov txuj ci Alexa. Ua ntej peb tsim daim ntawv thov nrog kev ua haujlwm yooj yim tshaj plaws: ua kom peb BLE lub teeb beacon beep thaum pib.

#!/usr/bin/env pythonfrom flask import Flask los ntawm flask_ask ntshuam nug, nqe lus ntshuam pexpect app = Flask (_ name_) nug = Nug (app, '/') BD_ADDR = 'AA: BB: CC: DD: EE: FF '#Koj bluetooth beacon id ntawm no @ask.intent (' findkeys ') def retrievr (): sound_alarm () speech_text = "Koj cov yuam sij nyob ib puag ncig ntawm no." xa cov lus (hais lus_text) def sound_alarm (): tus menyuam = pexpect.spawn ('gatttool -I') child.sendline ('txuas {}'. hom ntawv (BD_ADDR)) child.expect ('Kev sib txuas tau zoo', sij hawm = 60) child.sendline ('char-write-cmd 0x000b 0100111000000001') yog _name_ == "_main_": app.run (host = '127.0.0.1', chaw nres nkoj = '5000')

Peb siv lub luag haujlwm sound_alarm () peb tau sau ua ntej los ua BLE beep. Txog qhov ua haujlwm uas yuav siv rau lub hom phiaj, peb ntxiv tus kws kho kom zoo nkauj nrog peb lub hom phiaj "findkeys". Thaum peb ua qhov txuj ci Alexa ntawm Amazon tus tsim tawm dashboard peb yuav siv lub npe no rau peb lub hom phiaj. Sau tsab ntawv no rau cov ntaub ntawv npe app.py thiab khiav

nab hab sej app.py

Qhov no yuav ua haujlwm rau koj daim ntawv thov ntawm https:// localhost: 5000. Khiav tus neeg rau zaub mov ngrok thiab luam qhov txuas https tau tsim. Koj yuav xav tau nws thaum koj teeb tsa Alexa txuj ci. Yog xav paub ntxiv, mus saib nplooj ntawv no. Peb tau ua tiav teeb tsa daim ntawv thov yooj yim, tam sim no peb yuav sau qhov txuj ci Alexa. Nkag mus rau Amazon tus tsim tawm dashboard thiab nkag mus. Nyem rau ntawm Alexa thiab pib nrog Alexa Skill cov khoom

Ua raws li cov lus qhia los ntawm gui.

Nyob rau hauv Interation Model tab koj yuav xav ua kom tiav Lub Hom Phiaj Schema lub thawv nrog cov hauv qab no:

Hauv Sample Utterances lub thawv, koj xav sau qee cov lus txib piv txwv uas ib tus neeg yuav siv los ua kom muaj txuj ci. Peb sau cov no:

findkeys nrhiav kuv cov yuam sij nrhiav qhov twg kuv cov yuam sij findkeys Kuv poob kuv cov yuam sij

  • Hauv Configuration tab, nco ntsoov xaiv qhov kev pabcuam kawg rau HTTPS. Luam koj li https txuas thiab muab tso rau hauv lub thawv Default hauv qab no. Kev txuas tus as khauj tuaj yeem tawm mus rau No.
  • Hauv SSL Daim Ntawv Pov Thawj xaiv qhov nruab nrab qhov kev xaiv, "Kuv qhov kev txhim kho qhov kawg yog ib pawg ntawm cov npe uas muaj daim ntawv pov thawj tsiaj qus los ntawm daim ntawv pov thawj".
  • Qhov Test tab yuav tso cai rau koj sim qhov txuj ci tshiab los ntawm kev ntaus ib qho ntawm koj cov lus txib piv txwv.

Ua kom tiav ua tiav ob lub tab kawg kom txog rau thaum tag nrho cov cim kos yog ntsuab. Tom qab ntawd tshaj tawm koj cov txuj ci nrog Beta Testing feature. Qhov no tso cai rau koj los tuav koj cov txuj ci ntawm ib qho khoom siv ncha ua ntej tshaj tawm nws. Ua raws cov lus qhia ntawm email txuas txhawm rau txhim kho qhov txuj ci ntawm koj lub cuab yeej ncha.

Kauj Ruam 3: Ua Peb Li Kev Txawj Ntse

Ua Peb Li Kev Txawj Ntse
Ua Peb Li Kev Txawj Ntse
Ua Peb Li Kev Txawj Ntse
Ua Peb Li Kev Txawj Ntse
Ua Peb Li Kev Txawj Ntse
Ua Peb Li Kev Txawj Ntse

Peb tso cov khoos phis tawj tsis ua haujlwm thoob plaws lub tsev los ua haujlwm nug txog lub teeb ci bluetooth los tshaj tawm txog RSSI teeb liab lub zog.

Kev nyeem ntawv los ntawm ntau lub tshuab, peb tuaj yeem siv lub zog teeb liab los ua tus sawv cev rau qhov deb. Peb yuav tsum txiav txim siab yuav siv qhov no li cas los suav qhov feem ntau yuav yog ib feem ntawm lub tsev kom pom lub teeb.

Peb tig mus rau kev kawm tshuab. Ib txoj haujlwm crontab txhua 2 feeb, txhim kho cov ntaub ntawv ntawm RSSI tuples. Tso lub teeb ci rau ntau qhov chaw xws li: 'Chav pw', 'Chav Dej', 'Chav Ua Noj', 'Qhov Chaw Nyob' peb sau lo lus RSSI cav. Thaum peb tau teeb tsa lub tsev, peb tuaj yeem siv cov qauv ntoo raws li xgboost's XGBClassifier.

Xgboost kev ua tiav ntawm kev txhawb nqa gradient yuav lis cov ntaub ntawv uas ploj lawm los ntawm lub sijhawm nyeem tawm, kev qhia hauv ob peb feeb. Siv nab nab los txhawm rau txhawm rau ua tus qauv kev kawm thiab ntsaws rau hauv peb daim ntawv thov alexa retrievr. Thaum cov txuj ci hu ua, daim ntawv thov saib bluetooth RSSI nyeem ntawv thiab tsim qhov chaw kwv yees, alexa tuaj yeem teb tawm tswv yim rau 'sim saib hauv chav dej.'

Kauj Ruam 4: Muab Nws Txhua Qhov Ua Ke

Muaj tus qauv los kwv yees qhov chaw kawg ntawm cov yuam sij, peb tuaj yeem ntxiv nws rau hauv daim ntawv thov txhawm rau txhim kho cov lus xa rov qab los ntawm Alexa. Peb tau hloov tsab ntawv los nyeem:

ntshuam osfrom hwj ntshuam Flask los ntawm flask_ask ntshuam nug, nqe lus import pexpect ntshuam ntshuam ntshoo pandas li pd ntshuam numpy li np los ntawm kev sau ntshuam defaultdict, Counter from reverse_read import reverse_readline app = Flask (_ name_) ask = Ask (app, '/') @ ask.intent ('findkeys') def retrievr (): os.system ("/path/to/repo/sound_alarm.py &") speech_text = guess_locate () return statement (speech_text) def guess_locate (): read_dict = {} line_gen = reverse_readline ('YOUR_DATA_FILE.txt') res_lst = thaum len (res_lst)! = 20: ln = next (line_gen) if ln.startswith ('Host'): _, ip, _, nyeem ntawv = ln.split () read_dict [ip] = nyeem res_lst.append (read_dict) yog ip == 'ip.of.one.computer': read_dict = {} else: pass val = pd. DataFrame (res_lst).replace ({'N/ A ': np.nan}). Values mdl_ = pickle.load (open (' location_model_file.dat ',' rb ')) preds = mdl_.predict (val) guess = Counter (preds) guess = guess.most_common (1)) [0] [0] reply_str = 'Sim saib hauv' yog kwv yees == 1: reply_str += 'chav pw' elif twv == 2: reply_str += 'chav dej' elif twv == 3: reply_str += 'chav ua noj' elif kwv yees == 4: reply_str += 'chav nyob' rov teb reply_str yog _name_ == "_main_": app.run (host = '127.0.0.1', chaw nres nkoj = '5000')

Peb tsim txoj haujlwm tshiab hu ua guess_locate () uas yuav siv cov ntaub ntawv nrog qhov sau tseg yav dhau los rssi teeb liab ua tau zoo. Nws mam li khiav cov qauv tiv thaiv peb cov qauv xgboost pickled thiab xa rov qab qhov feem ntau yuav muaj txoj hlua. Qhov chaw no yuav raug xa rov qab thaum Alexa raug ceeb toom. Txij li tsim kom muaj kev sib txuas mus rau lub teeb ci tuaj yeem siv ob peb feeb, peb ua cov txheej txheem cais hu ua lub luag haujlwm hauv sound_alarm.py.

Pom zoo: