Get node id for page which is set for 403 and 404
You need to use

variable_get('site_403');
variable_get('site_404');


It will return a string like "node/1", then you just have to parse this string to get back the node ID.