diff --git a/chap/C.tex b/chap/C.tex index ad466e7..769ee7b 100644 --- a/chap/C.tex +++ b/chap/C.tex @@ -472,6 +472,36 @@ Libérer deux fois la mémoire. % ========================================================= +\section{Debug} \index{Debug} + +Des outils et astuces en page \pageref{chap:Debug}. + +\begin{quote} +splint is an annotation-assisted lightweight static checker. +It is a tool for +statically checking C programs for security vulnerabilities and coding +mistakes. +If additional effort is invested in adding annotations to programs, +splint can perform stronger checking. +\end{quote} + +% ========================================================= +\section{Legalize} + +"The two forms of conforming implementation are hosted and freestanding. +A conforming hosted implementation shall accept any strictly conforming +program. A conforming freestanding implementation shall accept any +strictly conforming program in which the use of the features specified +in the library clause (Clause 7) is confined to the contents of the +standard headers , , , , + , , , , and +. Additionally, a conforming freestanding implementation shall accept +any strictly conforming program in which the use of the features +specified in the header , except the following functions: +strdup , strndup , strcoll , strxfrm , strerror ." (4p6) + +% ========================================================= + \section{Ailleurs dans cet ouvrage} Il y a plein d'autres exemples de code en C, sur des sujets diff --git a/chap/DNS.tex b/chap/DNS.tex index 878971b..fc2b657 100644 --- a/chap/DNS.tex +++ b/chap/DNS.tex @@ -70,6 +70,8 @@ tth@tranxene:~$ \subsection{dig} \index{dig} +% https://jvns.ca/blog/2021/12/04/how-to-use-dig/ + Dig (\textit{domain information groper}) est un outil d'interrogation des serveurs DNS. Par défaut, il questionne les serveurs listés dans \texttt{/etc/resolv.conf}. @@ -80,6 +82,10 @@ Pour résoudre récursivement un nom de domaine à partir de la racine : Pour obtenir le reverse d'une adresse IP : \texttt{\$ dig +trace -x } + + + + % ------------------------------------------------------------ % \subsection{delv} % \index{delv} diff --git a/chap/debug.tex b/chap/debug.tex index 028a00a..484485e 100644 --- a/chap/debug.tex +++ b/chap/debug.tex @@ -180,43 +180,7 @@ Il nius faut donc remplacer le getenv de la libc par notre propre version qui va écouter et exfiltrer l'utilisation de cette fonction. -\begin{lstlisting}[language=C] -/* - spy_getenv.so: spy_getenv.c Makefile - gcc -Wall -shared -fPIC $< -ldl -o $@ -*/ - -#include -#include -#include -#define __USE_GNU -#include -typedef char * (*original_getenv)(const char *envname); - -char *getenv(char *envname) -{ -static char *arrow = "--getenv--> "; -static char *wtf = " --> WTF ?"; -char *content; - -original_getenv orig_getenv; -orig_getenv = (original_getenv)dlsym(RTLD_NEXT, "getenv"); - -write(STDERR_FILENO, arrow, strlen(arrow)); -write(STDERR_FILENO, envname, strlen(envname)); -content = orig_getenv(envname); -if (NULL != content) { - write(STDERR_FILENO, "=", 1); - write(STDERR_FILENO, content, strlen(content)); - } -else { - write(STDERR_FILENO, wtf, strlen(wtf)); - } - -write(STDERR_FILENO, "\n", 1); -return content; -} -\end{lstlisting} +\lstinputlisting[language=C]{code/debug/spy_getenv.c} Simple et efficace. diff --git a/chap/divers.tex b/chap/divers.tex index bebdff5..839368f 100644 --- a/chap/divers.tex +++ b/chap/divers.tex @@ -52,6 +52,11 @@ map_henon: map_henon.f Hélas, je n'ai pas de commande \texttt{g77} dans ma machine, que faire ? En écrire une ? +% ============================================================== +\section{qemu} +\index{qemu}\label{qemu} + +http://sven.stormbind.net/blog/posts/deb\_qemu\_local\_openwrt/ % ============================================================== diff --git a/chap/graphisme.tex b/chap/graphisme.tex index 8758604..5ddacf1 100644 --- a/chap/graphisme.tex +++ b/chap/graphisme.tex @@ -100,6 +100,27 @@ la commande\texttt{tail} au début du script. Ensuite les deux clauses coordonnées X et Z, dans le repère POVray, qui n'est pas le même que celui de Gnuplot. + +% ------------------------------------------------ +\subsection{image\_map} + +% ------------------------------------------------ + +\subsection{height\_field} + +Les champs d'altitude... Toute une histoire... + +\begin{verbatim} +#declare Champ_Altitude = object +{ +height_field { + png "WS/hf5.png" gamma 1.8 + } +pigment { color Cyan } +scale 2 +} +\end{verbatim} + % ------------------------------------------------ \subsection{Trucs à voir} @@ -107,15 +128,15 @@ celui de Gnuplot. \begin{verbatim} #declare VIRGINIA = -transform{ +transform { matrix < 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 > } -box{0,1 -transform{VIRGINIA} +box { 0, 1 +transform {VIRGINIA} } \end{verbatim} diff --git a/chap/image.tex b/chap/image.tex index 2190153..4ef8976 100644 --- a/chap/image.tex +++ b/chap/image.tex @@ -111,6 +111,12 @@ changer la dimension de l'image. En détail, j'ai pas tout compris. % ------------------------------------------ +\subsection{Trucs} + +convert -average frame*.png output.png + +% ------------------------------------------ + \subsection{Ressources} Le futur livre de Brunus. Réclamez les prmiers drafts dans diff --git a/chap/openwrt.tex b/chap/openwrt.tex index d762444..3bdaa9a 100644 --- a/chap/openwrt.tex +++ b/chap/openwrt.tex @@ -10,4 +10,4 @@ TP Link Archer C7 \end{verbatim} - +http://sven.stormbind.net/blog/posts/deb\_qemu\_local\_openwrt/ diff --git a/chap/slang.tex b/chap/slang.tex index 43ce0f8..2b810fc 100644 --- a/chap/slang.tex +++ b/chap/slang.tex @@ -2,6 +2,8 @@ \label{S-lang} \index{S-lang} +% ---------------------------------------------------------- + \section{C'est quoi ?} S-lang est une bibliothèque de fonctions multi-plateforme @@ -13,6 +15,8 @@ L'exemple le plus éblouissant étant le célèbre longuement dans les pages consacrées à Usenet\index{Usenet} (page \pageref{slrn}). +% ---------------------------------------------------------- + \section{slsh} \index{slsh} @@ -40,3 +44,4 @@ tth@plop:~/Essais/Slang$ Cool... +% ---------------------------------------------------------- diff --git a/chap/son.tex b/chap/son.tex index ccb33d3..ec19eb0 100644 --- a/chap/son.tex +++ b/chap/son.tex @@ -154,7 +154,7 @@ Elle supporte une grande variété de formats. La configuration se fait par deux fichiers : \texttt{/etc/libao.conf} surchargeable par -\texttt{\$HOME/.libao.conf}, et scématiquement, nous pouvons +\texttt{\$HOME/.libao.conf}, et schématiquement, nous pouvons voir qu'elle est à deux niveaux. https://www.xiph.org/ao/doc/drivers.html diff --git a/chap/webserver.tex b/chap/webserver.tex new file mode 100644 index 0000000..14fba01 --- /dev/null +++ b/chap/webserver.tex @@ -0,0 +1,62 @@ +% +% +% +\chapter{Web servers} + +% ============================================================== +\section{Apache} \index{Apache} + +Le grand classique. + + +% ============================================================== +\section{Lighttpd} \index{Lighttpd} + +Un outsider ? + +\begin{verbatim} +root@ramen:~# lighty-enable-mod userdir +Enabling userdir: ok +Run "service lighttpd force-reload" to enable changes +root@ramen:~# service lighttpd force-reload +root@ramen:~# +\end{verbatim} + +% ============================================================== + +\section{Custom made} + +\begin{verbatim} +tth@ramen:~/Houba/Fractales90$ apt show libmicrohttpd12 +Package: libmicrohttpd12 +Version: 0.9.72-2 +Priority: optional +Section: libs +Source: libmicrohttpd +Maintainer: Daniel Baumann +Installed-Size: 211 kB +Depends: libc6 (>= 2.17), libgnutls30 (>= 3.7.0) +Homepage: https://www.gnu.org/software/libmicrohttpd/ +Tag: role::shared-lib +Download-Size: 109 kB +APT-Sources: http://deb.debian.org/debian bullseye/main amd64 Packages +Description: library embedding HTTP server functionality + GNU libmicrohttpd is a small C library that is supposed to make it + easy to run an HTTP server as part of another application. + Key features that distinguish GNU Libmicrohttpd from other + projects are: + * C library: fast and small + * API is simple, expressive and fully reentrant + * Implementation is HTTP 1.1 compliant + * HTTP server can listen on multiple ports + * Four different threading models (select, poll, pthread, thread pool) + * Support for IPv6 + * Support for SHOUTcast + * Support for incremental processing of POST data (optional) + * Support for basic and digest authentication (optional) + * Support for SSL3 and TLS +\end{verbatim} + + +% ============================================================== + diff --git a/code/debug/spy_getenv.c b/code/debug/spy_getenv.c new file mode 100644 index 0000000..27a3f5c --- /dev/null +++ b/code/debug/spy_getenv.c @@ -0,0 +1,45 @@ +/* + * + * spy_getenv.so: spy_getenv.c Makefile + * gcc -Wall -shared -fPIC $< -ldl -o $@ + * + */ + +#include +#include +#include + +#define __USE_GNU +#include + +typedef char * (*original_getenv)(const char *envname); + +char *getenv(char *envname) +{ +static char *arrow = "--getenv--> "; +static char *wtf = " --> (nil)"; + +char *content; +original_getenv orig_getenv; + +orig_getenv = (original_getenv)dlsym(RTLD_NEXT, "getenv"); + +write(STDERR_FILENO, arrow, strlen(arrow)); +write(STDERR_FILENO, envname, strlen(envname)); + +content = orig_getenv(envname); +if (NULL != content) { + write(STDERR_FILENO, "=", 1); + write(STDERR_FILENO, content, strlen(content)); + } +else { + write(STDERR_FILENO, wtf, strlen(wtf)); + } + +write(STDERR_FILENO, "\n", 1); + +return content; +} + +/* j'adore quand un plan se déroule sans accrc */ + diff --git a/main.tex b/main.tex index 7126174..b743120 100644 --- a/main.tex +++ b/main.tex @@ -139,7 +139,6 @@ en ligne sur le site du Tetalab. Your mileage may vary\dots \input{chap/plugins} \input{chap/Bonjour} \input{chap/ioctl} - \input{chap/debug} \input{chap/buzybox} \input{chap/gif89a} @@ -148,11 +147,12 @@ en ligne sur le site du Tetalab. Your mileage may vary\dots \input{chap/Usenet} \input{chap/DNS} \input{chap/ssh} +\input{chap/webserver} \input{chap/hardware} \input{chap/gadgets} \input{chap/sdr} -% \input{chap/slang} +\input{chap/slang} \input{chap/curses} \input{chap/openwrt} \input{chap/WiFi}