\documentclass{report}

\usepackage{etoolbox}


\makeatletter
\apptocmd{\@chapter}{\gdef\currentchapter{#2}}{}{}
\def\currentchapter{?}
\apptocmd{\@section}{\gdef\currentsection{#2}}{}{}
\def\currentsection{?}
\makeatother

\begin{document}
\chapter{Salam}

\section{A Section}
\currentsection

\currentchapter
\section{Hello}
\currentsection

\end{document}