I would define my own listings environment (\lstnewenvironment) which draws the box using TikZ around the listing:
\documentclass{article}
\usepackage{listings}
\usepackage{tikz}
\newlength{\cornerlength}
\setlength{\cornerlength}{1cm}
\tikzset{listingborder/.style={thick}}
\makeatletter
\lstnewenvironment{mylisting}[1][]{%
\lstset{#1}%
\setbox0\hbox\bgroup\color@setgroup
}{%
\color@endgroup\egroup
\begin{tikzpicture}
\node (L) [text width=\linewidth] {%
\usebox{0}%
};
\draw [listingborder]
(L.north west)
-- ([xshift=-\cornerlength]L.north east)
-- ([yshift=-\cornerlength]L.north east)
-- (L.south east)
-- (L.south west)
-- cycle;
\draw [listingborder]
([yshift=-\cornerlength]L.north east)
-| ([xshift=-\cornerlength]L.north east);
\end{tikzpicture}%
}
\makeatother
\begin{document}
\begin{mylisting}[language=tex,basicstyle=\ttfamily]
\lstnewenvironment{mylisting}[1][]{%
\lstset{#1}%
\setbox0\hbox\bgroup\color@setgroup
}{%
\color@endgroup\egroup
\begin{tikzpicture}
\node (L) [text width=\linewidth] {%
\usebox{0}%
};
\draw [listingborder]
(L.north west)
-- ([xshift=-\cornerlength]L.north east)
-- ([yshift=-\cornerlength]L.north east)
-- (L.south east)
-- (L.south west)
-- cycle;
\draw [listingborder]
([yshift=-\cornerlength]L.north east)
-| ([xshift=-\cornerlength]L.north east);
\end{tikzpicture}%
}
\end{mylisting}
\end{document}

You still need to add the waved line at the bottom. Also note that usually you can wrap the node around the environment content be replacing \node {..}; with \node \bgroup and \egroup;, however, this didn't worked for the listings environment. Most likely some of the verbatim trickery causes issues. (This is funny because verbatim should work inside a TikZ node)
\lstnewenvironment) which draws the box using TikZ around the listing. – Martin Scharrer Aug 05 '11 at 10:33