On a category archive, the “queried object” will have what you need.
$cat = get_queried_object();
var_dump($cat->cat_ID);
You can access it by means of get_query_var()
:
$cat = get_query_var('cat');
var_dump($cat);
You can also pull is straight from the $wp_query
global:
var_dump($wp_query->query_vars['cat']);
All of these assume that you are actually on a proper category archive page and that nothing has clobbered or otherwise corrupted the main query.